/** * Gte woocommerce data for product * * @param $value * @param $data * * @return string */ function vc_gitem_template_attribute_woocommerce_product($value, $data) { $label = ''; /** * @var null|Wp_Post $post ; * @var string $data ; */ extract(array_merge(array('post' => null, 'data' => ''), $data)); require_once WC()->plugin_path() . '/includes/abstracts/abstract-wc-product.php'; $product = new WC_Product($post); if (preg_match('/_labeled$/', $data)) { $data = preg_replace('/_labeled$/', '', $data); $label = apply_filters('vc_gitem_template_attribute_woocommerce_product_' . $data . '_label', Vc_Vendor_Woocommerce::getProductFieldLabel($data) . ': '); } $price_format = get_woocommerce_price_format(); switch ($data) { case 'id': $value = (int) $product->is_type('variation') ? $product->get_variation_id() : $product->id; break; case 'sku': $value = $product->get_sku(); break; case 'price': $value = sprintf($price_format, wc_format_decimal($product->get_price(), 2), get_woocommerce_currency()); break; case 'regular_price': $value = sprintf($price_format, wc_format_decimal($product->get_regular_price(), 2), get_woocommerce_currency()); break; case 'sale_price': $value = sprintf(get_woocommerce_price_format(), $product->get_sale_price() ? wc_format_decimal($product->get_sale_price(), 2) : '', get_woocommerce_currency()); break; case 'price_html': $value = $product->get_price_html(); break; case 'reviews_count': $value = count(get_comments(array('post_id' => $post->ID, 'approve' => 'approve'))); break; case 'short_description': $value = apply_filters('woocommerce_short_description', $product->get_post_data()->post_excerpt); break; case 'dimensions': $units = get_option('woocommerce_dimension_unit'); $value = $product->length . $units . 'x' . $product->width . $units . 'x' . $product->height . $units; break; case 'raiting_count': $value = $product->get_rating_count(); break; case 'weight': $value = $product->get_weight() ? wc_format_decimal($product->get_weight(), 2) : ''; break; case 'on_sale': $value = $product->is_on_sale() ? 'yes' : 'no'; // @todo change break; default: $value = $product->{$data}; } return strlen($value) > 0 ? $label . apply_filters('vc_gitem_template_attribute_woocommerce_product_' . $data . '_value', $value) : ''; }
/** * Get standard product data that applies to every product type * * @since 2.1 * @param WC_Product $product * @return array */ private function get_product_data($product) { return array('title' => $product->get_name(), 'id' => $product->get_id(), 'created_at' => $this->server->format_datetime($product->get_date_created(), false, true), 'updated_at' => $this->server->format_datetime($product->get_date_modified(), false, true), 'type' => $product->get_type(), 'status' => $product->get_status(), 'downloadable' => $product->is_downloadable(), 'virtual' => $product->is_virtual(), 'permalink' => $product->get_permalink(), 'sku' => $product->get_sku(), 'price' => wc_format_decimal($product->get_price(), 2), 'regular_price' => wc_format_decimal($product->get_regular_price(), 2), 'sale_price' => $product->get_sale_price() ? wc_format_decimal($product->get_sale_price(), 2) : null, 'price_html' => $product->get_price_html(), 'taxable' => $product->is_taxable(), 'tax_status' => $product->get_tax_status(), 'tax_class' => $product->get_tax_class(), 'managing_stock' => $product->managing_stock(), 'stock_quantity' => $product->get_stock_quantity(), 'in_stock' => $product->is_in_stock(), 'backorders_allowed' => $product->backorders_allowed(), 'backordered' => $product->is_on_backorder(), 'sold_individually' => $product->is_sold_individually(), 'purchaseable' => $product->is_purchasable(), 'featured' => $product->is_featured(), 'visible' => $product->is_visible(), 'catalog_visibility' => $product->get_catalog_visibility(), 'on_sale' => $product->is_on_sale(), 'weight' => $product->get_weight() ? wc_format_decimal($product->get_weight(), 2) : null, 'dimensions' => array('length' => $product->get_length(), 'width' => $product->get_width(), 'height' => $product->get_height(), 'unit' => get_option('woocommerce_dimension_unit')), 'shipping_required' => $product->needs_shipping(), 'shipping_taxable' => $product->is_shipping_taxable(), 'shipping_class' => $product->get_shipping_class(), 'shipping_class_id' => 0 !== $product->get_shipping_class_id() ? $product->get_shipping_class_id() : null, 'description' => apply_filters('the_content', $product->get_description()), 'short_description' => apply_filters('woocommerce_short_description', $product->get_short_description()), 'reviews_allowed' => $product->get_reviews_allowed(), 'average_rating' => wc_format_decimal($product->get_average_rating(), 2), 'rating_count' => $product->get_rating_count(), 'related_ids' => array_map('absint', array_values(wc_get_related_products($product->get_id()))), 'upsell_ids' => array_map('absint', $product->get_upsell_ids()), 'cross_sell_ids' => array_map('absint', $product->get_cross_sell_ids()), 'categories' => wc_get_object_terms($product->get_id(), 'product_cat', 'name'), 'tags' => wc_get_object_terms($product->get_id(), 'product_tag', 'name'), 'images' => $this->get_images($product), 'featured_src' => wp_get_attachment_url(get_post_thumbnail_id($product->get_id())), 'attributes' => $this->get_attributes($product), 'downloads' => $this->get_downloads($product), 'download_limit' => $product->get_download_limit(), 'download_expiry' => $product->get_download_expiry(), 'download_type' => 'standard', 'purchase_note' => apply_filters('the_content', $product->get_purchase_note()), 'total_sales' => $product->get_total_sales(), 'variations' => array(), 'parent' => array()); }
function hocwp_wc_is_sale($post_id = null) { $post_id = hocwp_return_post($post_id, 'id'); if (hocwp_id_number_valid($post_id)) { $pro = new WC_Product($post_id); return $pro->is_on_sale(); } global $product; return $product->is_on_sale(); }
/** * Get product data. * * @param WC_Product $product Product instance. * @return array */ protected function get_product_data($product) { $data = array('id' => $product->get_id(), 'name' => $product->get_name(), 'slug' => $product->get_slug(), 'permalink' => $product->get_permalink(), 'date_created' => wc_rest_prepare_date_response($product->get_date_created()), 'date_modified' => wc_rest_prepare_date_response($product->get_date_modified()), 'type' => $product->get_type(), 'status' => $product->get_status(), 'featured' => $product->is_featured(), 'catalog_visibility' => $product->get_catalog_visibility(), 'description' => wpautop(do_shortcode($product->get_description())), 'short_description' => apply_filters('woocommerce_short_description', $product->get_short_description()), 'sku' => $product->get_sku(), 'price' => $product->get_price(), 'regular_price' => $product->get_regular_price(), 'sale_price' => $product->get_sale_price() ? $product->get_sale_price() : '', 'date_on_sale_from' => $product->get_date_on_sale_from() ? date('Y-m-d', $product->get_date_on_sale_from()) : '', 'date_on_sale_to' => $product->get_date_on_sale_to() ? date('Y-m-d', $product->get_date_on_sale_to()) : '', 'price_html' => $product->get_price_html(), 'on_sale' => $product->is_on_sale(), 'purchasable' => $product->is_purchasable(), 'total_sales' => $product->get_total_sales(), 'virtual' => $product->is_virtual(), 'downloadable' => $product->is_downloadable(), 'downloads' => $this->get_downloads($product), 'download_limit' => $product->get_download_limit(), 'download_expiry' => $product->get_download_expiry(), 'download_type' => 'standard', 'external_url' => $product->is_type('external') ? $product->get_product_url() : '', 'button_text' => $product->is_type('external') ? $product->get_button_text() : '', 'tax_status' => $product->get_tax_status(), 'tax_class' => $product->get_tax_class(), 'manage_stock' => $product->managing_stock(), 'stock_quantity' => $product->get_stock_quantity(), 'in_stock' => $product->is_in_stock(), 'backorders' => $product->get_backorders(), 'backorders_allowed' => $product->backorders_allowed(), 'backordered' => $product->is_on_backorder(), 'sold_individually' => $product->is_sold_individually(), 'weight' => $product->get_weight(), 'dimensions' => array('length' => $product->get_length(), 'width' => $product->get_width(), 'height' => $product->get_height()), 'shipping_required' => $product->needs_shipping(), 'shipping_taxable' => $product->is_shipping_taxable(), 'shipping_class' => $product->get_shipping_class(), 'shipping_class_id' => $product->get_shipping_class_id(), 'reviews_allowed' => $product->get_reviews_allowed(), 'average_rating' => wc_format_decimal($product->get_average_rating(), 2), 'rating_count' => $product->get_rating_count(), 'related_ids' => array_map('absint', array_values(wc_get_related_products($product->get_id()))), 'upsell_ids' => array_map('absint', $product->get_upsell_ids()), 'cross_sell_ids' => array_map('absint', $product->get_cross_sell_ids()), 'parent_id' => $product->get_parent_id(), 'purchase_note' => wpautop(do_shortcode(wp_kses_post($product->get_purchase_note()))), 'categories' => $this->get_taxonomy_terms($product), 'tags' => $this->get_taxonomy_terms($product, 'tag'), 'images' => $this->get_images($product), 'attributes' => $this->get_attributes($product), 'default_attributes' => $this->get_default_attributes($product), 'variations' => array(), 'grouped_products' => array(), 'menu_order' => $product->get_menu_order()); return $data; }
function TS_VCSC_WooCommerce_Grid_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-visual-composer-extend-front'); } } else { wp_enqueue_script('ts-extend-hammer'); wp_enqueue_script('ts-extend-nacho'); wp_enqueue_style('ts-extend-nacho'); wp_enqueue_style('ts-extend-dropdown'); wp_enqueue_script('ts-extend-dropdown'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-extend-animations'); wp_enqueue_style('dashicons'); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-extend-buttons'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-extend-isotope'); wp_enqueue_script('ts-visual-composer-extend-front'); } add_action('wp_footer', array($this, 'TS_VCSC_WooCommerce_Grid_Function_Isotope'), 9999); } extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'show_image' => 'true', 'show_link' => 'true', 'link_page' => 'false', 'link_target' => '_parent', 'show_rating' => 'true', 'show_stock' => 'true', 'show_price' => 'true', 'show_cart' => 'true', 'show_info' => 'true', 'show_content' => 'excerpt', 'cutoff_characters' => 400, 'lightbox_group_name' => 'nachogroup', 'lightbox_size' => 'full', 'lightbox_effect' => 'random', 'lightbox_speed' => 5000, 'lightbox_social' => 'true', 'lightbox_backlight_choice' => 'predefined', 'lightbox_backlight_color' => '#0084E2', 'lightbox_backlight_custom' => '#000000', 'image_position' => 'ts-imagefloat-center', 'hover_type' => 'ts-imagehover-style1', 'hover_active' => 'false', 'overlay_trigger' => 'ts-trigger-hover', 'rating_maximum' => 5, 'rating_value' => 0, 'rating_dynamic' => '', 'rating_quarter' => 'true', 'rating_size' => 16, 'rating_auto' => 'false', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => 'ts-ecommerce-starfull1', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'false', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'post_type' => 'product', 'date_format' => 'F j, Y', 'time_format' => 'l, g:i A', 'filter_menu' => 'true', 'layout_menu' => 'true', 'sort_menu' => 'false', 'directions_menu' => 'false', 'filter_by' => 'product_cat', 'layout' => 'masonry', 'column_width' => 285, 'layout_break' => 600, 'show_periods' => 'false', 'sort_by' => 'postName', 'sort_order' => 'asc', 'posts_limit' => 25, 'posts_lazy' => 'false', 'posts_ajax' => 10, 'posts_load' => 'Show More', 'posts_trigger' => 'click', 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); $postsgrid_random = mt_rand(999999, 9999999); $opening = $closing = $controls = $products = ''; $posts_limit = $products_total; if (!empty($el_id)) { $posts_container_id = $el_id; } else { $posts_container_id = 'ts-vcsc-woocommerce-grid-' . $postsgrid_random; } // Backlight Color if ($lightbox_backlight_choice == "predefined") { $lightbox_backlight_selection = $lightbox_backlight_color; } else { $lightbox_backlight_selection = $lightbox_backlight_custom; } // Check for Front End Editor if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { $product_style = ''; $frontend_edit = 'true'; $description_style = 'display: none; padding: 15px;'; } else { $product_style = ''; $frontend_edit = 'false'; $description_style = 'display: none; padding: 15px;'; } $meta_query = ''; // Recent Products if ($selection == "recent_products") { $meta_query = WC()->query->get_meta_query(); } // Featured Products if ($selection == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } // Top Rated Products if ($selection == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } // Final Query Arguments $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query); // Products on Sale if ($selection == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } // Best Selling Products if ($selection == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } // Products in Single Category if ($selection == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } // Products in Multiple Categories if ($selection == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN')); } $menu_tax = 'product_cat'; $limit_tax = 'product_cat'; // Start WordPress Query $loop = new WP_Query($args); // Language Settings: Isotope Posts $TS_VCSC_Isotope_Posts_Language = get_option('ts_vcsc_extend_settings_translationsIsotopePosts', ''); if ($TS_VCSC_Isotope_Posts_Language == false || empty($TS_VCSC_Isotope_Posts_Language)) { $TS_VCSC_Isotope_Posts_Language = $VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_Isotope_Posts_Language_Defaults; } if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Grid_Basic', $atts); } else { $css_class = ''; } if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == 'false') { $isotope_posts_list_class = 'ts-posts-timeline-view'; } else { $isotope_posts_list_class = 'ts-posts-timeline-edit'; } if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == 'true') { echo '<div id="ts-isotope-posts-grid-frontend-' . $postsgrid_random . '" class="ts-isotope-posts-grid-frontend" style="border: 1px solid #ededed; padding: 10px;">'; echo '<div style="font-weight: bold;">"Basic Products Isotope Grid"</div>'; echo '<div style="margin-bottom: 20px;">The element has been disabled in order to ensure compatiblity with the Visual Composer Front-End Editor.</div>'; echo '<div>' . __("Number of Products", "ts_visual_composer_extend") . ': ' . $posts_limit . '</div>'; $front_edit_reverse = array("excerpt" => __('Excerpt', "ts_visual_composer_extend"), "cutcharacters" => __('Character Limited Content', "ts_visual_composer_extend"), "complete" => __('Full Content', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $show_content) { echo '<div>' . __("Content Length", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("masonry" => __('Centered Masonry', "ts_visual_composer_extend"), "fitRows" => __('Fit Rows', "ts_visual_composer_extend"), "straightDown" => __('Straight Down', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $layout) { echo '<div>' . __("Content", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("postName" => __('Product Name', "ts_visual_composer_extend"), "postPrice" => __('Product Price', "ts_visual_composer_extend"), "postRating" => __('Product Rating', "ts_visual_composer_extend"), "postDate" => __('Product Date', "ts_visual_composer_extend"), "postModified" => __('Product Modified', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $sort_by) { echo '<div>' . __("Sort Criterion", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("asc" => __('Bottom to Top', "ts_visual_composer_extend"), "desc" => __('Top to Bottom', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $sort_order) { echo '<div>' . __("Initial Order", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } echo '<div>' . __("Show Filter Button", "ts_visual_composer_extend") . ': ' . $filter_menu . '</div>'; echo '<div>' . __("Show Layout Button", "ts_visual_composer_extend") . ': ' . $layout_menu . '</div>'; echo '<div>' . __("Show Sort Criterion Button", "ts_visual_composer_extend") . ': ' . $sort_menu . '</div>'; echo '<div>' . __("Show Directions Buttons", "ts_visual_composer_extend") . ': ' . $directions_menu . '</div>'; echo '</div>'; } else { $opening .= '<div id="' . $posts_container_id . '" class="ts-isotope-posts-grid-parent ' . ($layout == 'spineTimeline' ? 'ts-timeline ' : 'ts-postsgrid ') . 'ts-timeline-' . $sort_order . ' ts-posts-timeline ' . $isotope_posts_list_class . ' ' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . ';" data-lazy="' . $posts_lazy . '" data-count="' . $posts_limit . '" data-ajax="' . $posts_ajax . '" data-trigger="' . $posts_trigger . '" data-column="' . $column_width . '" data-layout="' . $layout . '" data-sort="' . $sort_by . '" data-order="' . $sort_order . '" data-break="' . $layout_break . '" data-type="' . $post_type . '">'; // Create Individual Post Output $postCounter = 0; $postCategories = array(); $categoriesCount = 0; if (post_type_exists($post_type) && $loop->have_posts()) { $products .= '<div class="ts-timeline-content">'; $products .= '<ul id="ts-isotope-posts-grid-' . $postsgrid_random . '" class="ts-isotope-posts-grid ts-timeline-list" data-layout="' . $layout . '" data-key="' . $postsgrid_random . '">'; while ($loop->have_posts()) { $loop->the_post(); $postCounter++; $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; $onsale = $product->is_on_sale() ? 'true' : 'false'; // Rating Settings $rating_html = $product->get_rating_html(); $rating = $product->get_average_rating(); if ($rating == '') { $rating = 0; } if ($rating_quarter == "true") { $rating_value = floor($rating * 4) / 4; } else { $rating_value = $rating; } $rating_value = number_format($rating_value, 2, $caption_digits, ''); if ($rating_rtl == "false") { $rating_width = $rating_value / $rating_maximum * 100; } else { $rating_width = 100 - $rating_value / $rating_maximum * 100; } if ($rating_symbol == "other") { if ($rating_icon == "ts-ecommerce-starfull1") { $rating_class = 'ts-rating-stars-star1'; } else { if ($rating_icon == "ts-ecommerce-starfull2") { $rating_class = 'ts-rating-stars-star2'; } else { if ($rating_icon == "ts-ecommerce-starfull3") { $rating_class = 'ts-rating-stars-star3'; } else { if ($rating_icon == "ts-ecommerce-starfull4") { $rating_class = 'ts-rating-stars-star4'; } else { if ($rating_icon == "ts-ecommerce-heartfull") { $rating_class = 'ts-rating-stars-heart1'; } else { if ($rating_icon == "ts-ecommerce-heart") { $rating_class = 'ts-rating-stars-heart2'; } else { if ($rating_icon == "ts-ecommerce-thumbsup") { $rating_class = 'ts-rating-stars-thumb'; } else { if ($rating_icon == "ts-ecommerce-ribbon4") { $rating_class = 'ts-rating-stars-ribbon'; } } } } } } } } } else { $rating_class = 'ts-rating-stars-smile'; } if ($rating_value >= 0 && $rating_value <= 1) { $caption_class = 'ts-label-danger'; $caption_background = 'background-color: ' . $caption_danger . ';'; } else { if ($rating_value > 1 && $rating_value <= 2) { $caption_class = 'ts-label-warning'; $caption_background = 'background-color: ' . $caption_warning . ';'; } else { if ($rating_value > 2 && $rating_value <= 3) { $caption_class = 'ts-label-info'; $caption_background = 'background-color: ' . $caption_info . ';'; } else { if ($rating_value > 3 && $rating_value <= 4) { $caption_class = 'ts-label-primary'; $caption_background = 'background-color: ' . $caption_primary . ';'; } else { if ($rating_value > 4 && $rating_value <= 5) { $caption_class = 'ts-label-success'; $caption_background = 'background-color: ' . $caption_success . ';'; } } } } } if (has_post_thumbnail($loop->post->ID)) { $featured = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $featured = $featured[0]; $thumbnail = $thumbnail[0]; } else { $featured = woocommerce_placeholder_img_src(); $thumbnail = $featured; } $title = get_the_title(); // Create Output if ($postCounter < $posts_limit + 1) { $postAttributes = 'data-visible="false" data-price="' . TS_VCSC_CleanNumberData($product->price) . '" data-rating="' . TS_VCSC_CleanNumberData($rating) . '" data-full="' . get_post_time($date_format) . '" data-author="' . get_the_author() . '" data-date="' . get_post_time('U') . '" data-modified="' . get_the_modified_time('U') . '" data-title="' . get_the_title() . '" data-comments="' . get_comments_number() . '" data-id="' . get_the_ID() . '"'; if ($exclude_outofstock == "true" && $stock == "true" || $exclude_outofstock == "false") { $product_categories = ''; if ($filter_menu == 'true' && taxonomy_exists($menu_tax)) { foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) { $product_categories .= $term->slug . ' '; $category_check = 0; foreach ($postCategories as $index => $array) { if ($postCategories[$index]['slug'] == $term->slug) { $category_check++; } } if ($category_check == 0) { $categoriesCount++; $categories_array = array('slug' => $term->slug, 'name' => $term->name); $postCategories[] = $categories_array; } } } $product_categories .= 'rating-' . TS_VCSC_CleanNumberData($rating) . ' '; $products .= '<li class="ts-timeline-list-item ts-timeline-date-true ts-isotope-posts-list-item ' . $product_categories . '" ' . $postAttributes . ' style="margin: 10px;">'; $products .= '<div class="ts-woocommerce-product-slide" style="' . $product_style . '" data-hash="' . $product_id . '">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '" class="ts-image-hover-frame ' . $image_position . ' ts-trigger-hover-adjust" style="width: 100%;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-counter" class="ts-fluid-wrapper " style="width: 100%; height: auto;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-mask" class="ts-imagehover ' . $hover_type . ' ts-trigger-hover" data-trigger="ts-trigger-hover" data-closer="" style="width: 100%; height: auto;">'; // Product Thumbnail $products .= '<div class="ts-woocommerce-product-preview">'; $products .= '<img class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $products .= '</div>'; // Sale Ribbon if ($onsale == "true") { $products .= '<div class="ts-woocommerce-product-ribbon"></div>'; $products .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-sale ts-ecommerce-tagsale"></i>'; } $products .= '<div class="ts-woocommerce-product-main">'; $products .= '<div class="mask" style="width: 100%; display: block;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-maskcontent" class="maskcontent" style="margin: 0; padding: 0;">'; // Product Thubmnail if ($show_image == "true") { if ($link_page == "false") { $products .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="nch-lightbox-media" data-title="' . $title . '" rel="" href="' . $featured . '" target="' . $link_target . '">'; $products .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $products .= '</a></div>'; } else { $products .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="" data-title="' . $title . '" rel="" href="' . get_permalink() . '" target="' . $link_target . '">'; $products .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $products .= '</a></div>'; } } // Product Page Link if ($show_link == "true") { $products .= '<div class="ts-woocommerce-link-wrapper"><a href="' . get_permalink() . '" class="ts-woocommerce-product-link" target="_blank"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a></div>'; } // Product Rating if ($show_rating == "true") { $products .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 10px 0 0 10px; float: left;">'; $products .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $products .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $products .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $products .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $products .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; } // Product Price if ($show_price == "true") { $products .= '<div class="ts-woocommerce-product-price">'; $products .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $products .= '<div class="ts-woocommerce-product-regular"><del>' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $products .= '</div>'; } $products .= '<div class="ts-woocommerce-product-line"></div>'; // Add to Cart Button (Icon) if ($show_cart == "true") { $products .= '<div class="ts-woocommerce-link-wrapper"><a class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a></div>'; } // View Description Button if ($show_info == "true") { $products .= '<div id="ts-vcsc-modal-' . $product_id . '-trigger" style="" class="ts-vcsc-modal-' . $product_id . '-parent nch-holder ts-vcsc-font-icon ts-font-icons ts-shortcode ts-icon-align-center" style="">'; $products .= '<a href="#ts-vcsc-modal-' . $product_id . '" class="nch-lightbox-modal" data-title="" data-open="false" data-delay="0" data-type="html" rel="" data-effect="' . $lightbox_effect . '" data-share="0" data-duration="' . $lightbox_speed . '" data-color="' . $lightbox_backlight_selection . '">'; $products .= '<span class="">'; $products .= '<i class="ts-font-icon ts-woocommerce-product-icon ts-woocommerce-product-info ts-ecommerce-information1" style=""></i>'; $products .= '</span>'; $products .= '</a>'; $products .= '</div>'; } // Product In-Stock or Unavailable if ($show_stock == "true") { $products .= '<div class="ts-woocommerce-product-status">'; if ($stock == 'false') { $products .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-outofstock">' . __('Out of Stock', 'woocommerce') . '</span></div>'; } else { if ($stock == 'true') { $products .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-instock">' . __('In Stock', 'woocommerce') . '</span></div>'; } } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; // Product Title $products .= '<h2 class="ts-woocommerce-product-title">'; $products .= $title; $products .= '</h2>'; // Product Description if ($show_info == "true") { $products .= '<div id="ts-vcsc-modal-' . $product_id . '" class="ts-modal-content nch-hide-if-javascript" style="' . $description_style . '">'; $products .= '<div class="ts-modal-white-header"></div>'; $products .= '<div class="ts-modal-white-frame">'; $products .= '<div class="ts-modal-white-inner">'; $products .= '<h2 style="border-bottom: 1px solid #eeeeee; padding-bottom: 10px; line-height: 32px; font-size: 24px; text-align: left;">' . $title . '</h2>'; $products .= '<div class="ts-woocommerce-lightbox-frame" style="width: 100%; height: 32px; margin: 10px auto; padding: 0;">'; $products .= '<a style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; $products .= '<a href="' . get_permalink() . '" target="_parent" style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-link"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a>'; $products .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 0; float: right;">'; $products .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $products .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $products .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $products .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $products .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '<div class="ts-woocommerce-product-price" style="position: inherit; margin-right: 10px; float: left; width: auto; margin-top: 0;">'; $products .= '<i style="color: #000000; margin: 0 10px 0 0;" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $products .= '<div class="ts-woocommerce-product-regular"><del style="color: #7F0000;">' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 10px auto 20px auto; width: 100%;"></div>'; $products .= '<img style="width: 100%; max-width: 250px; height: auto; margin: 10px auto;" class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $products .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 20px auto 10px auto; width: 100%;"></div>'; $products .= '<div style="margin-top: 20px; text-align: justify;">'; if ($show_content == "excerpt") { $products .= get_the_excerpt(); } else { if ($show_content == "cutcharacters") { $content = apply_filters('the_content', get_the_content()); $excerpt = TS_VCSC_TruncateHTML($content, $cutoff_characters, '...', false, true); $products .= $excerpt; } else { if ($show_content == "complete") { $products .= get_the_content(); } } } $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; } $products .= '</div>'; $products .= '</li>'; } } } $products .= '</ul>'; $products .= '</div>'; if ($posts_lazy == "true") { $products .= '<div class="ts-load-more-wrap">'; $products .= '<span class="ts-timeline-load-more">' . $posts_load . '</span>'; $products .= '</div>'; } wp_reset_postdata(); } else { $products .= '<p>Nothing found. Please check back soon!</p>'; } // Create Post Controls (Filter, Sort) $controls .= '<div id="ts-isotope-posts-grid-controls-' . $postsgrid_random . '" class="ts-isotope-posts-grid-controls">'; if ($directions_menu == 'true' && $posts_lazy == 'false') { $controls .= '<div class="ts-button ts-button-flat ts-timeline-controls-desc ts-isotope-posts-controls-desc ' . ($sort_order == "desc" ? "active" : "") . '"><span class="ts-isotope-posts-controls-desc-image"></span></div>'; $controls .= '<div class="ts-button ts-button-flat ts-timeline-controls-asc ts-isotope-posts-controls-asc ' . ($sort_order == "asc" ? "active" : "") . '"><span class="ts-isotope-posts-controls-asc-image"></span></div>'; } $controls .= '<div class="ts-isotope-posts-grid-controls-menus">'; if ($filter_menu == 'true') { if ($categoriesCount > 1) { $controls .= '<div id="ts-isotope-posts-filter-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-filter-trigger" data-dropdown="#ts-isotope-posts-filter-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['WooFilterProducts'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-filter-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label style="font-weight: bold;"><input class="ts-isotope-posts-filter ts-isotope-posts-filter-all" type="checkbox" style="margin-right: 10px;" checked="checked" data-type="all" data-key="' . $postsgrid_random . '" data-filter="*">' . $TS_VCSC_Isotope_Posts_Language['SeeAll'] . '</label></li>'; $controls .= '<li class="ts-dropdown-divider"></li>'; foreach ($postCategories as $index => $array) { $controls .= '<li><label><input class="ts-isotope-posts-filter ts-isotope-posts-filter-single" type="checkbox" style="margin-right: 10px;" data-type="single" data-key="' . $postsgrid_random . '" data-filter=".' . $postCategories[$index]['slug'] . '">' . $postCategories[$index]['name'] . '</label></li>'; } $controls .= '</ul>'; $controls .= '</div>'; } } if ($layout_menu == 'true') { $controls .= '<div id="ts-isotope-posts-layout-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-layout-trigger" data-dropdown="#ts-isotope-posts-layout-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['ButtonLayout'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-layout-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="masonry" style="margin-right: 10px;" ' . ($layout == 'masonry' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['Masonry'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="fitRows" style="margin-right: 10px;" ' . ($layout == 'fitRows' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['FitRows'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="straightDown" style="margin-right: 10px;" ' . ($layout == 'straightDown' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['StraightDown'] . '</label></li>'; $controls .= '</ul>'; $controls .= '</div>'; } if ($sort_menu == 'true') { $controls .= '<div id="ts-isotope-posts-sort-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-sort-trigger" data-dropdown="#ts-isotope-posts-sort-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['ButtonSort'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-sort-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postName" style="margin-right: 10px;" ' . ($sort_by == 'postName' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooTitle'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postPrice" style="margin-right: 10px;" ' . ($sort_by == 'postPrice' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooPrice'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postRatings" style="margin-right: 10px;" ' . ($sort_by == 'postRatings' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooRating'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postDate" style="margin-right: 10px;" ' . ($sort_by == 'postDate' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooDate'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postModified" style="margin-right: 10px;" ' . ($sort_by == 'postModified' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooModified'] . '</label></li>'; $controls .= '</ul>'; $controls .= '</div>'; } $controls .= '</div>'; $controls .= '<div class="clearFixMe" style="clear:both;"></div>'; $controls .= '</div>'; $closing .= '</div>'; echo $opening; echo $controls; echo $products; echo $closing; } $myvariable = ob_get_clean(); return $myvariable; }
/** * Gets an individual ticket * * @param $event_id * @param $ticket_id * * @return null|Tribe__Events__Tickets__Ticket_Object */ public function get_ticket($event_id, $ticket_id) { if (class_exists('WC_Product_Simple')) { $product = new WC_Product_Simple($ticket_id); } else { $product = new WC_Product($ticket_id); } if (!$product) { return null; } $return = new Tribe__Events__Tickets__Ticket_Object(); $product_data = $product->get_post_data(); $qty = get_post_meta($ticket_id, 'total_sales', true); $return->description = $product_data->post_excerpt; $return->frontend_link = get_permalink($ticket_id); $return->ID = $ticket_id; $return->name = $product->get_title(); $return->price = $product->get_price(); $return->regular_price = $product->get_regular_price(); $return->on_sale = (bool) $product->is_on_sale(); $return->provider_class = get_class($this); $return->admin_link = admin_url(sprintf(get_post_type_object($product_data->post_type)->_edit_link . '&action=edit', $ticket_id)); $return->stock = $product->get_stock_quantity(); $return->start_date = get_post_meta($ticket_id, '_ticket_start_date', true); $return->end_date = get_post_meta($ticket_id, '_ticket_end_date', true); $return->qty_sold = $qty ? $qty : 0; $return->qty_pending = $qty ? $this->count_incomplete_order_items($ticket_id) : 0; $return->purchase_limit = get_post_meta($ticket_id, '_ticket_purchase_limit', true); if (empty($return->purchase_limit) && 0 !== (int) $return->purchase_limit) { /** * Filter the default purchase limit for the ticket * * @var int * * @return int */ $return->purchase_limit = apply_filters('tribe_tickets_default_purchase_limit', 0); } return apply_filters('wootickets_get_ticket', $return, $event_id, $ticket_id); }
function WooComposer_Loop_style04($atts, $element) { global $woocommerce; $product_style = $display_elements = $quick_view_style = $img_animate = $text_align = $color_heading = $color_categories = $color_price = ''; $color_rating = $color_rating_bg = $color_quick_bg = $color_quick = $color_cart_bg = $color_cart = $color_product_desc = $advanced_opts = ''; $color_product_desc_bg = $size_title = $size_cat = $size_price = $color_on_sale = $color_on_sale_bg = $label_on_sale = $product_animation = ''; $disp_type = $category = $output = $product_style = $border_style = $border_color = $border_size = $border_radius = $lazy_images = $pagination = ''; $sale_price = $shortcode = $on_sale_alignment = $on_sale_style = $product_img_disp = ''; extract(shortcode_atts(array("disp_type" => "", "category" => "", "shortcode" => "", "product_style" => "style01", "display_elements" => "", "quick_view_style" => "expandable", "label_on_sale" => "Sale!", "text_align" => "left", "img_animate" => "rotate-clock", "pagination" => "", "color_heading" => "", "color_categories" => "", "color_price" => "", "color_rating" => "", "color_rating_bg" => "", "color_quick_bg" => "", "color_quick" => "", "color_cart_bg" => "", "color_on_sale_bg" => "", "color_on_sale" => "", "color_cart" => "", "color_product_desc" => "", "color_product_desc_bg" => "", "size_title" => "", "size_cat" => "", "size_price" => "", "border_style" => "", "border_color" => "", "border_size" => "", "border_radius" => "", "product_animation" => "", "lazy_images" => "", "advanced_opts" => "", "sale_price" => "", "on_sale_style" => "wcmp-sale-circle", "on_sale_alignment" => "wcmp-sale-right", "product_img_disp" => "single"), $atts)); $output = $heading_style = $cat_style = $price_style = $cart_style = $cart_bg_style = $view_style = $view_bg_style = $rating_style = ''; $desc_style = $label_style = $on_sale = $class = $style = $border = $desc_style = $sale_price_size = ''; $image_size = apply_filters('single_product_large_thumbnail_size', 'shop_single'); $img_animate = 'wcmp-img-' . $img_animate; if ($sale_price !== '') { $sale_price_size = 'font-size:' . $sale_price . 'px;'; } if ($border_style !== '') { $border .= 'border:' . $border_size . 'px ' . $border_style . ' ' . $border_color . ';'; $border .= 'border-radius:' . $border_radius . 'px;'; } if ($color_product_desc_bg !== '') { $desc_style .= 'background:' . $color_product_desc_bg . ';'; } if ($color_product_desc !== '') { $desc_style .= 'color:' . $color_product_desc . ';'; } $columns = 3; $display_type = $disp_type; if ($color_heading !== "") { $heading_style = 'color:' . $color_heading . ';'; } if ($size_title !== "") { $heading_style .= 'font-size:' . $size_title . 'px;'; } if ($color_categories !== "") { $cat_style = 'color:' . $color_categories . ';'; } if ($size_cat !== "") { $cat_style .= 'font-size:' . $size_cat . 'px;'; } if ($color_price !== "") { $price_style = 'color:' . $color_price . ';'; } if ($size_price !== "") { $price_style .= 'font-size:' . $size_price . 'px;'; } if ($color_rating !== "") { $rating_style .= 'color:' . $color_rating . ';'; } if ($color_rating_bg !== "") { $rating_style .= 'background:' . $color_rating_bg . ';'; } if ($color_quick_bg !== "") { $view_bg_style = 'background:' . $color_quick_bg . ';'; } if ($color_quick !== "") { $view_style = 'color:' . $color_quick . ';'; } if ($color_cart_bg !== "") { $cart_bg_style = 'background:' . $color_cart_bg . ';'; } if ($color_cart !== "") { $cart_style = 'color:' . $color_cart . ';'; } if ($color_on_sale_bg !== "") { $label_style = 'background:' . $color_on_sale_bg . ';'; } if ($color_on_sale !== "") { $label_style .= 'color:' . $color_on_sale . ';'; } $elemets = explode(",", $display_elements); if ($element == "grid") { $paged = get_query_var('paged') ? get_query_var('paged') : 1; } else { $paged = 1; } $post_count = '12'; /* $output .= do_shortcode($content); */ if ($shortcode !== '') { $new_shortcode = rawurldecode(base64_decode(strip_tags($shortcode))); } $pattern = get_shortcode_regex(); $shortcode_str = $short_atts = ''; preg_match_all("/" . $pattern . "/", $new_shortcode, $matches); $shortcode_str = str_replace('"', '', str_replace(" ", "&", trim($matches[3][0]))); $short_atts = parse_str($shortcode_str); //explode("&",$shortcode_str); if (isset($matches[2][0])) { $display_type = $matches[2][0]; } else { $display_type = ''; } if (!isset($columns)) { $columns = '4'; } if (isset($per_page)) { $post_count = $per_page; } if (isset($number)) { $post_count = $number; } if (!isset($order)) { $order = 'asc'; } if (!isset($orderby)) { $orderby = 'date'; } if (!isset($category)) { $category = ''; } if (!isset($ids)) { $ids = ''; } if ($ids) { $ids = explode(',', $ids); $ids = array_map('trim', $ids); } $col = $columns; if ($columns == "2") { $columns = 6; } elseif ($columns == "3") { $columns = 4; } elseif ($columns == "4") { $columns = 3; } $meta_query = ''; if ($display_type == "recent_products") { $meta_query = WC()->query->get_meta_query(); } if ($display_type == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } if ($display_type == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $post_count, 'orderby' => $orderby, 'order' => $order, 'paged' => $paged, 'meta_query' => $meta_query); if ($display_type == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } if ($display_type == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } if ($display_type == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } if ($display_type == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => $ids, 'field' => 'term_id', 'operator' => 'IN')); } $test = ''; if (vc_is_inline()) { $test = "wcmp_vc_inline"; } if ($product_animation == '') { $product_animation = 'no-animation'; } else { $style .= 'opacity:1;'; } if ($element == "grid") { $class = 'vc_span' . $columns . ' '; } $output .= '<div class="woocomposer ' . $test . '" data-columns="' . $col . '">'; $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $product_id = get_the_ID(); $uid = uniqid(); $output .= '<div id="product-' . $uid . '" style="' . $style . '" class="' . $class . ' wpb_column column_container wooproduct" data-animation="animated ' . $product_animation . '">'; if ($element == 'carousel') { $output .= '<div class="wcmp-carousel-item">'; } $product_title = get_the_title($product_id); $post = get_post($product_id); $product_desc = get_post($product_id)->post_excerpt; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $rating = $product->get_rating_html(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'InStock' : 'OutOfStock'; if ($product->is_on_sale()) { $on_sale = apply_filters('woocommerce_sale_flash', $label_on_sale, $post, $product); } else { $on_sale = ''; } if ($quick_view_style == "expandable") { $quick_view_class = 'quick-view-loop'; } else { $quick_view_class = 'quick-view-loop-popup'; } $cat_count = sizeof(get_the_terms($product_id, 'product_cat')); $tag_count = sizeof(get_the_terms($product_id, 'product_tag')); $categories = $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>'); $tags = $product->get_tags(', ', '<span class="tagged_as">' . _n('', '', $tag_count, 'woocommerce') . ' ', '.</span>'); $output .= "\n" . '<div class="wcmp-product woocommerce wcmp-' . $product_style . ' ' . $img_animate . '" style="' . $border . ' ' . $desc_style . '">'; $output .= "\n\t" . '<div class="wcmp-product-image">'; if (empty($attachment_ids) && count($attachment_ids) > 1 && $product_img_disp == "carousel") { $uniqid = uniqid(); $output .= '<div class="wcmp-single-image-carousel carousel-in-loop">'; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; foreach ($attachment_ids as $attachment_id) { $product_img = wp_get_attachment_image_src($attachment_id, $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; } $output .= '</div>'; } else { $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<a href="' . get_permalink($product_id) . '"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></a>'; } if ($stock == 'OutOfStock') { $output .= "\n" . '<span class="wcmp-out-stock">' . __('Out Of Stock!', 'woocomposer') . '</span>'; } if ($on_sale !== '') { $output .= "\n" . '<div class="wcmp-onsale ' . $on_sale_alignment . ' ' . $on_sale_style . '"><span class="onsale" style="' . $label_style . ' ' . $sale_price_size . '">' . $on_sale . '</span></div>'; } $output .= '<div class="wcmp-add-to-cart" style="' . $cart_bg_style . '"><a style="' . $cart_style . '" title="Add to Cart" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-product_id="' . $product_id . '" data-product_sku="" class="add_to_cart_button product_type_simple"><i class="wooicon-cart4"></i></a></div>'; if (in_array("quick", $elemets)) { $output .= '<div class="wcmp-quick-view ' . $quick_view_class . '" style="' . $view_bg_style . '"><a style="' . $view_style . '" title="Quick View" href="' . get_permalink($product_id) . '"><i class="wooicon-plus32"></i></a></div>'; } if (in_array("reviews", $elemets)) { $output .= "\n" . '<div class="wcmp-star-ratings" style="' . $rating_style . '">' . $rating . '</div>'; } $output .= '</div>'; $output .= "\n\t" . '<div class="wcmp-product-desc">'; $output .= '<a href="' . get_permalink($product_id) . '">'; $output .= "\n\t\t" . '<h2 style="' . $heading_style . '">' . $product_title . '</h2>'; $output .= '</a>'; if (in_array("category", $elemets)) { $output .= '<h5 style="' . $cat_style . '">'; if ($categories !== '') { $output .= $categories; $output .= $tags; } $output .= '</h5>'; } $output .= "\n\t\t" . '<div class="wcmp-price"><span class="price" style="' . $price_style . '">' . $price . '</span></div>'; if (in_array("description", $elemets)) { $output .= "\n\t\t" . '<div class="wcmp-product-content" style="' . $desc_style . '">' . $product_desc . '</div>'; } $output .= "\n\t" . '</div>'; $output .= "\n\t" . '</div>'; if (in_array("quick", $elemets)) { $output .= '<div class="wcmp-quick-view-wrapper woocommerce" data-columns="' . $col . '">'; if ($quick_view_style !== "expandable") { $output .= '<div class="wcmp-quick-view-wrapper woocommerce product">'; $output .= '<div class="wcmp-close-single"><i class="wooicon-cross2"></i></div>'; } $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<div class="wcmp-single-image wcmp-quickview-img images"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div>'; if ($quick_view_style !== "expandable") { $output .= '<div class="wcmp-product-content-single">'; } else { $output .= '<div class="wcmp-product-content">'; } ob_start(); do_action('woocommerce_single_product_summary'); $output .= ob_get_clean(); $output .= '</div>'; $output .= '<div class="clear"></div>'; if ($quick_view_style !== "expandable") { $output .= '</div>'; } $output .= '</div>'; } $output .= "\n" . '</div>'; if ($element == 'carousel') { $output .= "\n\t" . '</div>'; } } } if ($pagination == "enable") { $output .= '<div class="wcmp-paginate">'; $output .= woocomposer_pagination($query->max_num_pages); $output .= '</div>'; } $output .= '</div>'; if ($display_type == "top_rated_products") { remove_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); } wp_reset_postdata(); return $output; }
global $product; ?> <?php $woolink = $product->product_type == 'external' ? $product->add_to_cart_url() : get_post_permalink(get_the_ID()); $term_ids = wp_get_post_terms(get_the_ID(), 'product_tag', array("fields" => "ids")); if (!empty($term_ids)) { $term_brand = $term_ids[0]; $term_brand_image = get_option("taxonomy_term_{$term_ids['0']}"); } else { $term_brand_image = ''; } ?> <div class="rehub_feat_block table_view_block"><a name="woo-link-list"></a> <?php if ($product->is_on_sale()) { ?> <div class="vip_corner"><span class="vip_badge sale_badge">Sale!</span></div><?php } ?> <div class="block_with_coupon"> <div class="offer_thumb"> <a href="<?php echo $woolink; ?> " target="_blank"><?php wpsm_thumb('med_thumbs'); ?> </a> </div>
/** * Gets an individual ticket * * @param $event_id * @param $ticket_id * * @return null|Tribe__Tickets__Ticket_Object */ public function get_ticket($event_id, $ticket_id) { if (class_exists('WC_Product_Simple')) { $product = new WC_Product_Simple($ticket_id); } else { $product = new WC_Product($ticket_id); } if (!$product) { return null; } $return = new Tribe__Tickets__Ticket_Object(); $product_data = $product->get_post_data(); $qty = get_post_meta($ticket_id, 'total_sales', true); $return->description = $product_data->post_excerpt; $return->frontend_link = get_permalink($ticket_id); $return->ID = $ticket_id; $return->name = $product->get_title(); $return->price = $product->get_price(); $return->regular_price = $product->get_regular_price(); $return->on_sale = (bool) $product->is_on_sale(); $return->provider_class = get_class($this); $return->admin_link = admin_url(sprintf(get_post_type_object($product_data->post_type)->_edit_link . '&action=edit', $ticket_id)); $return->start_date = get_post_meta($ticket_id, '_ticket_start_date', true); $return->end_date = get_post_meta($ticket_id, '_ticket_end_date', true); $return->purchase_limit = get_post_meta($ticket_id, '_ticket_purchase_limit', true); $complete_totals = $this->count_order_items_by_status($ticket_id, 'complete'); $pending_totals = $this->count_order_items_by_status($ticket_id, 'incomplete'); $qty = $qty ? $qty : 0; $pending = $pending_totals['total'] ? $pending_totals['total'] : 0; // if any orders transitioned from complete back to one of the incomplete states, their quantities // were already recorded in total_sales and we have to deduct them from there so they aren't // double counted $qty -= $pending_totals['recorded_sales']; // let's calculate the stock based on the product stock minus the quantity purchased minus the // pending purchases $stock = $product->get_stock_quantity() - $qty - $pending; // if any orders have reduced the stock of an order (check and cash on delivery payments do this, for example) // we need to re-inflate the stock by that amount $stock += $pending_totals['reduced_stock']; $stock += $complete_totals['reduced_stock']; $return->manage_stock($product->managing_stock()); $return->stock($stock); $return->qty_sold($qty); $return->qty_pending($pending); $return->qty_cancelled($this->get_cancelled($ticket_id)); if (empty($return->purchase_limit) && 0 !== (int) $return->purchase_limit) { /** * Filter the default purchase limit for the ticket * * @var int * * @return int */ $return->purchase_limit = apply_filters('tribe_tickets_default_purchase_limit', 0); } return apply_filters('wootickets_get_ticket', $return, $event_id, $ticket_id); }
function woo_products_carousel_func($atts, $content = null) { extract(shortcode_atts(array('animation' => '', 'animation_delay' => '', 'animation_iteration' => '', 'title' => '', 'orderby' => '', 'limit' => '', 'show' => '', 'order' => '', 'style' => '', 'length' => '', 'double_product' => 'no'), $atts)); if (!class_exists('woocommerce')) { return ''; } ob_start(); global $post; $query_args = array('posts_per_page' => $limit, 'post_status' => 'publish', 'post_type' => 'product', 'no_found_rows' => 1, 'order' => $order == 'asc' ? 'asc' : 'desc'); $query_args['meta_query'] = array(); if (empty($instance['show_hidden'])) { $query_args['meta_query'][] = WC()->query->visibility_meta_query(); $query_args['post_parent'] = 0; } if (!empty($instance['hide_free'])) { $query_args['meta_query'][] = array('key' => '_price', 'value' => 0, 'compare' => '>', 'type' => 'DECIMAL'); } $query_args['meta_query'][] = WC()->query->stock_status_meta_query(); $query_args['meta_query'] = array_filter($query_args['meta_query']); switch ($show) { case 'featured': $query_args['meta_query'][] = array('key' => '_featured', 'value' => 'yes'); break; case 'onsale': $product_ids_on_sale = wc_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $query_args['post__in'] = $product_ids_on_sale; break; } switch ($orderby) { case 'price': $query_args['meta_key'] = '_price'; $query_args['orderby'] = 'meta_value_num'; break; case 'rand': $query_args['orderby'] = 'rand'; break; case 'sales': $query_args['meta_key'] = 'total_sales'; $query_args['orderby'] = 'meta_value_num'; break; default: $query_args['orderby'] = 'date'; } ?> <div class="carousel-box bottom-padding bottom-padding-mini load overflow <?php echo ts_get_animation_class($animation); ?> " <?php echo ts_get_animation_data_class($animation_delay, $animation_iteration); ?> > <?php if ($style == 'style3') { $title_box = ''; } else { $title_box = 'no-margin'; } ?> <div class="title-box <?php echo sanitize_html_class($title_box); ?> "> <a class="next" href="#"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="9px" height="16px" viewBox="0 0 9 16" enable-background="new 0 0 9 16" xml:space="preserve"> <polygon fill-rule="evenodd" clip-rule="evenodd" fill="#fcfcfc" points="1,0.001 0,1.001 7,8 0,14.999 1,15.999 9,8 "></polygon> </svg> </a> <a class="prev" href="#"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="9px" height="16px" viewBox="0 0 9 16" enable-background="new 0 0 9 16" xml:space="preserve"> <polygon fill-rule="evenodd" clip-rule="evenodd" fill="#fcfcfc" points="8,15.999 9,14.999 2,8 9,1.001 8,0.001 0,8 "></polygon> </svg> </a> <h2 class="title"><?php echo esc_html($title); ?> </h2> </div> <div class="clearfix"></div> <div class="row"> <div class="carousel products"> <?php $j = 1; $k = 1; $loop = new WP_Query($query_args); if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); $temp = 1; $product = new WC_Product(get_the_ID()); if ($style == 'style2') { $col = 'col-lg-4 col-md-4 col-sm-4 col-xs-12 double-product'; } elseif ($style == 'style1') { $col = 'col-lg-3 col-md-3 col-sm-3 col-xs-12 double-product'; } elseif ($style == 'style3') { $col = 'product product-mini col-sm-2 col-md-2'; } ?> <?php if ($double_product == 'yes') { if (++$j % 2 == 0) { echo '<div class="' . sanitize_html_classes($col) . '">'; } } else { echo '<div class="' . sanitize_html_classes($col) . '">'; } ?> <?php if ($style == 'style3') { $product_class = ''; } else { $product_class = 'product rotation'; } ?> <div class="<?php echo sanitize_html_classes($product_class); ?> "> <div class="default"> <?php if ($product->is_on_sale()) { ?> <?php echo apply_filters('woocommerce_sale_flash', '<span class="onsale">' . __('Sale!', 'woocommerce') . '</span>', $post, $product); ?> <?php } ?> <a href="<?php echo esc_url(get_the_permalink()); ?> " class="product-image"> <?php echo get_the_post_thumbnail($post->ID, 'shop_catalog'); ?> </a> <div class="product-description"> <div class="vertical"> <h3 class="product-name"> <a href="<?php echo esc_url(get_the_permalink()); ?> " class="xv_product_title"><?php the_title(); ?> </a> </h3> <div class="price"> <?php echo $product->get_price_html(); ?> </div> </div> </div> </div> <?php if ($style != 'style3') { $text_limit = 220; if ($style == 'style1') { $text_limit = 300; } ?> <div class="product-hover"> <h3 class="product-name"> <a href="<?php echo esc_url(get_the_permalink()); ?> " class="xv_product_title"><?php the_title(); ?> </a> </h3> <div class="price"><?php echo $product->get_price_html(); ?> </div> <a href="<?php echo esc_url(get_the_permalink()); ?> " class="product-image"> <?php echo get_the_post_thumbnail($post->ID, 'shop_catalog'); ?> </a> <div class="short-description"> <?php echo nl2br(trim(ts_get_shortened_string_by_letters(strip_tags($post->post_excerpt), $text_limit))); ?> </div> <div class="actions"> <?php wc_get_template('/loop/add-to-cart.php'); ?> <?php if (class_exists('YITH_WCWL')) { echo do_shortcode('[yith_wcwl_add_to_wishlist]'); } ?> <a href="<?php echo esc_url(get_the_permalink()); ?> " class="add-compare"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="16px" height="16px" viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve"> <path fill="#1e1e1e" d="M16,3.063L13,0v2H1C0.447,2,0,2.447,0,3s0.447,1,1,1h12v2L16,3.063z"></path> <path fill="#1e1e1e" d="M16,13.063L13,10v2H1c-0.553,0-1,0.447-1,1s0.447,1,1,1h12v2L16,13.063z"></path> <path fill="#1e1e1e" d="M15,7H3V5L0,7.938L3,11V9h12c0.553,0,1-0.447,1-1S15.553,7,15,7z"></path> </svg> </a> </div><!-- .actions --> </div><!-- .product-hover --> <?php } ?> </div> <?php if ($double_product == 'yes') { if ($k == 2) { echo '</div>'; $k = 0; } } else { echo '</div>'; } ?> <?php $k++; } } else { echo __('No products found', 'progressive'); } wp_reset_postdata(); ?> </div> </div> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
function TS_VCSC_WooCommerce_Slider_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); wp_enqueue_script('ts-extend-hammer'); wp_enqueue_script('ts-extend-nacho'); wp_enqueue_style('ts-extend-nacho'); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndWaypoints == "true") { if (wp_script_is('waypoints', $list = 'registered')) { wp_enqueue_script('waypoints'); } else { wp_enqueue_script('ts-extend-waypoints'); } } wp_enqueue_style('ts-extend-owlcarousel2'); wp_enqueue_script('ts-extend-owlcarousel2'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-extend-animations'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-visual-composer-extend-front'); extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'show_image' => 'true', 'link_page' => 'false', 'link_target' => '_parent', 'show_rating' => 'true', 'show_stock' => 'true', 'show_price' => 'true', 'show_link' => 'true', 'show_cart' => 'true', 'show_info' => 'true', 'show_content' => 'excerpt', 'cutoff_characters' => 400, 'products_slide' => 4, 'breakpoints_custom' => 'false', 'breakpoints_items' => '1,2,3,4,5,6,7,8', 'auto_height' => 'false', 'page_rtl' => 'false', 'auto_play' => 'false', 'show_bar' => 'false', 'bar_color' => '#dd3333', 'show_speed' => 5000, 'stop_hover' => 'true', 'show_navigation' => 'true', 'show_dots' => 'true', 'items_loop' => 'false', 'animation_in' => 'ts-viewport-css-flipInX', 'animation_out' => 'ts-viewport-css-slideOutDown', 'animation_mobile' => 'false', 'lightbox_group_name' => 'nachogroup', 'lightbox_size' => 'full', 'lightbox_effect' => 'random', 'lightbox_speed' => 5000, 'lightbox_social' => 'true', 'lightbox_backlight_choice' => 'predefined', 'lightbox_backlight_color' => '#0084E2', 'lightbox_backlight_custom' => '#000000', 'image_position' => 'ts-imagefloat-center', 'hover_type' => 'ts-imagehover-style1', 'hover_active' => 'false', 'overlay_trigger' => 'ts-trigger-hover', 'rating_maximum' => 5, 'rating_value' => 0, 'rating_quarter' => 'true', 'rating_dynamic' => '', 'rating_size' => 16, 'rating_auto' => 'false', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => 'ts-ecommerce-starfull1', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'false', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); $woo_random = mt_rand(999999, 9999999); if (!empty($el_id)) { $woo_slider_id = $el_id; } else { $woo_slider_id = 'ts-vcsc-woocommerce-slider-' . $woo_random; } $output = ''; // Backlight Color if ($lightbox_backlight_choice == "predefined") { $lightbox_backlight_selection = $lightbox_backlight_color; } else { $lightbox_backlight_selection = $lightbox_backlight_custom; } // Check for Front End Editor if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { $slider_class = 'owl-carousel2-edit'; $slider_message = '<div class="ts-composer-frontedit-message">' . __('The slider is currently viewed in front-end edit mode; slider features are disabled for performance and compatibility reasons.', "ts_visual_composer_extend") . '</div>'; $product_style = 'width: ' . 100 / $products_slide . '%; height: 100%; float: left; margin: 0; padding: 0;'; $frontend_edit = 'true'; $description_style = 'display: none; padding: 15px;'; } else { $slider_class = 'ts-owlslider-parent owl-carousel2'; $slider_message = ''; $product_style = ''; $frontend_edit = 'false'; $description_style = 'display: none; padding: 15px;'; } $meta_query = ''; // Recent Products if ($selection == "recent_products") { $meta_query = WC()->query->get_meta_query(); } // Featured Products if ($selection == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } // Top Rated Products if ($selection == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } // Final Query Arguments $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $frontend_edit == "true" ? $products_slide : $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query); // Products on Sale if ($selection == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } // Best Selling Products if ($selection == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } // Products in Single Category if ($selection == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } // Products in Multiple Categories if ($selection == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN')); } // Start WordPress Query $loop = new WP_Query($args); if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $slider_class . ' ' . $el_class . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Slider_Basic', $atts); } else { $css_class = $slider_class . ' ' . $el_class; } $output .= '<div id="' . $woo_slider_id . '-container" class="ts-woocommerce-slider-container">'; // Add Progressbar if ($auto_play == "true" && $show_bar == "true" && $frontend_edit == "false") { $output .= '<div id="ts-owlslider-progressbar-' . $woo_random . '" class="ts-owlslider-progressbar-holder" style=""><div class="ts-owlslider-progressbar" style="background: ' . $bar_color . '; height: 100%; width: 0%;"></div></div>'; } // Add Navigation Controls if ($frontend_edit == "false") { $output .= '<div id="ts-owlslider-controls-' . $woo_random . '" class="ts-owlslider-controls" style="' . ($auto_play == "true" || $show_navigation == "true" ? "display: block;" : "display: none;") . '">'; $output .= '<div id="ts-owlslider-controls-next-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>'; $output .= '<div id="ts-owlslider-controls-prev-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>'; if ($auto_play == "true") { $output .= '<div id="ts-owlslider-controls-play-' . $woo_random . '" class="ts-owlslider-controls-play active"><span class="ts-ecommerce-pause"></span></div>'; } $output .= '</div>'; } // Front-Edit Message if ($frontend_edit == "true") { $output .= $slider_message; } // Add Slider $output .= '<div id="' . $woo_slider_id . '" class="' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px;" data-id="' . $woo_random . '" data-items="' . $products_slide . '" data-breakpointscustom="' . $breakpoints_custom . '" data-breakpointitems="' . $breakpoints_items . '" data-rtl="' . $page_rtl . '" data-loop="' . $items_loop . '" data-navigation="' . $show_navigation . '" data-dots="' . $show_dots . '" data-mobile="' . $animation_mobile . '" data-animationin="' . $animation_in . '" data-animationout="' . $animation_out . '" data-height="' . $auto_height . '" data-play="' . $auto_play . '" data-bar="' . $show_bar . '" data-color="' . $bar_color . '" data-speed="' . $show_speed . '" data-hover="' . $stop_hover . '">'; if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; $onsale = $product->is_on_sale() ? 'true' : 'false'; // Rating Settings $rating_html = $product->get_rating_html(); $rating = $product->get_average_rating(); if ($rating == '') { $rating = 0; } if ($rating_quarter == "true") { $rating_value = floor($rating * 4) / 4; } else { $rating_value = $rating; } $rating_value = number_format($rating_value, 2, $caption_digits, ''); if ($rating_rtl == "false") { $rating_width = $rating_value / $rating_maximum * 100; } else { $rating_width = 100 - $rating_value / $rating_maximum * 100; } if ($rating_symbol == "other") { if ($rating_icon == "ts-ecommerce-starfull1") { $rating_class = 'ts-rating-stars-star1'; } else { if ($rating_icon == "ts-ecommerce-starfull2") { $rating_class = 'ts-rating-stars-star2'; } else { if ($rating_icon == "ts-ecommerce-starfull3") { $rating_class = 'ts-rating-stars-star3'; } else { if ($rating_icon == "ts-ecommerce-starfull4") { $rating_class = 'ts-rating-stars-star4'; } else { if ($rating_icon == "ts-ecommerce-heartfull") { $rating_class = 'ts-rating-stars-heart1'; } else { if ($rating_icon == "ts-ecommerce-heart") { $rating_class = 'ts-rating-stars-heart2'; } else { if ($rating_icon == "ts-ecommerce-thumbsup") { $rating_class = 'ts-rating-stars-thumb'; } else { if ($rating_icon == "ts-ecommerce-ribbon4") { $rating_class = 'ts-rating-stars-ribbon'; } } } } } } } } } else { $rating_class = 'ts-rating-stars-smile'; } if ($rating_value >= 0 && $rating_value <= 1) { $caption_class = 'ts-label-danger'; $caption_background = 'background-color: ' . $caption_danger . ';'; } else { if ($rating_value > 1 && $rating_value <= 2) { $caption_class = 'ts-label-warning'; $caption_background = 'background-color: ' . $caption_warning . ';'; } else { if ($rating_value > 2 && $rating_value <= 3) { $caption_class = 'ts-label-info'; $caption_background = 'background-color: ' . $caption_info . ';'; } else { if ($rating_value > 3 && $rating_value <= 4) { $caption_class = 'ts-label-primary'; $caption_background = 'background-color: ' . $caption_primary . ';'; } else { if ($rating_value > 4 && $rating_value <= 5) { $caption_class = 'ts-label-success'; $caption_background = 'background-color: ' . $caption_success . ';'; } } } } } if (has_post_thumbnail($loop->post->ID)) { $featured = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $featured = $featured[0]; $thumbnail = $thumbnail[0]; } else { $featured = woocommerce_placeholder_img_src(); $thumbnail = $featured; } $title = get_the_title(); if ($exclude_outofstock == "true" && $stock == "true" || $exclude_outofstock == "false") { $output .= '<div class="ts-woocommerce-product-slide" style="' . $product_style . '" data-hash="' . $product_id . '">'; $output .= '<div id="ts-woocommerce-product-' . $product_id . '" class="ts-image-hover-frame ' . $image_position . ' ts-trigger-hover-adjust" style="width: 100%;">'; $output .= '<div id="ts-woocommerce-product-' . $product_id . '-counter" class="ts-fluid-wrapper " style="width: 100%; height: auto;">'; $output .= '<div id="ts-woocommerce-product-' . $product_id . '-mask" class="ts-imagehover ' . $hover_type . ' ts-trigger-hover" data-trigger="ts-trigger-hover" data-closer="" style="width: 100%; height: auto;">'; // Product Thumbnail $output .= '<div class="ts-woocommerce-product-preview">'; $output .= '<img class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $output .= '</div>'; // Sale Ribbon if ($onsale == "true") { $output .= '<div class="ts-woocommerce-product-ribbon"></div>'; $output .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-sale ts-ecommerce-tagsale"></i>'; } $output .= '<div class="ts-woocommerce-product-main">'; $output .= '<div class="mask" style="width: 100%; display: block;">'; $output .= '<div id="ts-woocommerce-product-' . $product_id . '-maskcontent" class="maskcontent" style="margin: 0; padding: 0;">'; // Product Thubmnail if ($show_image == "true") { if ($link_page == "false") { $output .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="nch-lightbox-media no-ajaxy" data-title="' . $title . '" rel="" href="' . $featured . '" target="' . $link_target . '">'; $output .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $output .= '</a></div>'; } else { $output .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="" data-title="' . $title . '" rel="" href="' . get_permalink() . '" target="' . $link_target . '">'; $output .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $output .= '</a></div>'; } } // Product Page Link if ($show_link == "true") { $output .= '<div class="ts-woocommerce-link-wrapper"><a href="' . get_permalink() . '" class="ts-woocommerce-product-link" target="' . $link_target . '"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a></div>'; } // Product Rating if ($show_rating == "true") { $output .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 10px 0 0 10px; float: left;">'; $output .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $output .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $output .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $output .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $output .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '</div>'; $output .= '</div>'; } // Product Price if ($show_price == "true") { $output .= '<div class="ts-woocommerce-product-price">'; $output .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $output .= '<div class="ts-woocommerce-product-regular"><del>' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $output .= '</div>'; } $output .= '<div class="ts-woocommerce-product-line"></div>'; // Add to Cart Button (Icon) if ($show_cart == "true") { $output .= '<div class="ts-woocommerce-link-wrapper"><a class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a></div>'; } // View Description Button if ($show_info == "true") { $output .= '<div id="ts-vcsc-modal-' . $product_id . '-trigger" style="" class="ts-vcsc-modal-' . $product_id . '-parent nch-holder ts-vcsc-font-icon ts-font-icons ts-shortcode ts-icon-align-center" style="">'; $output .= '<a href="#ts-vcsc-modal-' . $product_id . '" class="nch-lightbox-modal" data-title="" data-open="false" data-delay="0" data-type="html" rel="" data-effect="' . $lightbox_effect . '" data-share="0" data-duration="' . $lightbox_speed . '" data-color="' . $lightbox_backlight_selection . '">'; $output .= '<span class="">'; $output .= '<i class="ts-font-icon ts-woocommerce-product-icon ts-woocommerce-product-info ts-ecommerce-information1" style=""></i>'; $output .= '</span>'; $output .= '</a>'; $output .= '</div>'; } // Product In-Stock or Unavailable if ($show_stock == "true") { $output .= '<div class="ts-woocommerce-product-status">'; if ($stock == 'false') { $output .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-outofstock">' . __('Out of Stock', 'woocommerce') . '</span></div>'; } else { if ($stock == 'true') { $output .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-instock">' . __('In Stock', 'woocommerce') . '</span></div>'; } } $output .= '</div>'; } $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; // Product Title $output .= '<h2 class="ts-woocommerce-product-title">'; $output .= $title; $output .= '</h2>'; // Product Description if ($show_info == "true") { $output .= '<div id="ts-vcsc-modal-' . $product_id . '" class="ts-modal-content nch-hide-if-javascript" style="' . $description_style . '">'; $output .= '<div class="ts-modal-white-header"></div>'; $output .= '<div class="ts-modal-white-frame">'; $output .= '<div class="ts-modal-white-inner">'; $output .= '<h2 style="border-bottom: 1px solid #eeeeee; padding-bottom: 10px; line-height: 32px; font-size: 24px; text-align: left;">' . $title . '</h2>'; $output .= '<div class="ts-woocommerce-lightbox-frame" style="width: 100%; height: 32px; margin: 10px auto; padding: 0;">'; $output .= '<a style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; $output .= '<a href="' . get_permalink() . '" target="_parent" style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-link"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a>'; $output .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 0; float: right;">'; $output .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $output .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $output .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $output .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $output .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '</div>'; $output .= '</div>'; $output .= '<div class="ts-woocommerce-product-price" style="position: inherit; margin-right: 10px; float: left; width: auto; margin-top: 0;">'; $output .= '<i style="color: #000000; margin: 0 10px 0 0;" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $output .= '<div class="ts-woocommerce-product-regular"><del style="color: #7F0000;">' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $output .= '</div>'; $output .= '</div>'; $output .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 10px auto 20px auto; width: 100%;"></div>'; $output .= '<img style="width: 100%; max-width: 250px; height: auto; margin: 10px auto;" class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $output .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 20px auto 10px auto; width: 100%;"></div>'; $output .= '<div style="margin-top: 20px; text-align: justify;">'; if ($show_content == "excerpt") { $output .= get_the_excerpt(); } else { if ($show_content == "cutcharacters") { $content = apply_filters('the_content', get_the_content()); $excerpt = TS_VCSC_TruncateHTML($content, $cutoff_characters, '...', false, true); $output .= $excerpt; } else { if ($show_content == "complete") { $output .= get_the_content(); } } } $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; } $output .= '</div>'; } } } else { echo __("No products could be found.", "ts_visual_composer_extend"); } $output .= '</div>'; $output .= '</div>'; wp_reset_postdata(); wp_reset_query(); echo $output; $myvariable = ob_get_clean(); return $myvariable; }
/** * Get standard product data that applies to every product type * * @since 2.1 * @param WC_Product $product * @return WC_Product */ private function get_product_data($product, $fields = null) { if ($fields) { $field_list = explode(',', $fields); } $product_data = array(); if (!$fields || $fields && in_array('title', $field_list)) { $product_data['title'] = $product->get_title(); } if (!$fields || $fields && in_array('id', $field_list)) { $product_data['id'] = (int) $product->is_type('variation') ? $product->get_variation_id() : $product->id; } if (!$fields || $fields && in_array('created_at', $field_list)) { $product_data['created_at'] = $this->server->format_datetime($product->get_post_data()->post_date_gmt); } if (!$fields || $fields && in_array('updated_at', $field_list)) { $product_data['updated_at'] = $this->server->format_datetime($product->get_post_data()->post_modified_gmt); } if (!$fields || $fields && in_array('type', $field_list)) { $product_data['type'] = $product->product_type; } if (!$fields || $fields && in_array('status', $field_list)) { $product_data['status'] = $product->get_post_data()->post_status; } if (!$fields || $fields && in_array('downloadable', $field_list)) { $product_data['downloadable'] = $product->is_downloadable(); } if (!$fields || $fields && in_array('virtual', $field_list)) { $product_data['virtual'] = $product->is_virtual(); } if (!$fields || $fields && in_array('permalink', $field_list)) { $product_data['permalink'] = $product->get_permalink(); } if (!$fields || $fields && in_array('sku', $field_list)) { $product_data['sku'] = $product->get_sku(); } if (!$fields || $fields && in_array('price', $field_list)) { $product_data['price'] = $product->get_price(); } if (!$fields || $fields && in_array('regular_price', $field_list)) { $product_data['regular_price'] = $product->get_regular_price(); } if (!$fields || $fields && in_array('sale_price', $field_list)) { $product_data['sale_price'] = $product->get_sale_price() ? $product->get_sale_price() : null; } if (!$fields || $fields && in_array('price_html', $field_list)) { $product_data['price_html'] = $product->get_price_html(); } if (!$fields || $fields && in_array('taxable', $field_list)) { $product_data['taxable'] = $product->is_taxable(); } if (!$fields || $fields && in_array('tax_status', $field_list)) { $product_data['tax_status'] = $product->get_tax_status(); } if (!$fields || $fields && in_array('tax_class', $field_list)) { $product_data['tax_class'] = $product->get_tax_class(); } if (!$fields || $fields && in_array('managing_stock', $field_list)) { $product_data['managing_stock'] = $product->managing_stock(); } if (!$fields || $fields && in_array('stock_quantity', $field_list)) { $product_data['stock_quantity'] = $product->get_stock_quantity(); } if (!$fields || $fields && in_array('in_stock', $field_list)) { $product_data['in_stock'] = $product->is_in_stock(); } if (!$fields || $fields && in_array('backorders_allowed', $field_list)) { $product_data['backorders_allowed'] = $product->backorders_allowed(); } if (!$fields || $fields && in_array('backordered', $field_list)) { $product_data['backordered'] = $product->is_on_backorder(); } if (!$fields || $fields && in_array('sold_individually', $field_list)) { $product_data['sold_individually'] = $product->is_sold_individually(); } if (!$fields || $fields && in_array('purchaseable', $field_list)) { $product_data['purchaseable'] = $product->is_purchasable(); } if (!$fields || $fields && in_array('featured', $field_list)) { $product_data['featured'] = $product->is_featured(); } if (!$fields || $fields && in_array('visible', $field_list)) { $product_data['visible'] = $product->is_visible(); } if (!$fields || $fields && in_array('catalog_visibility', $field_list)) { $product_data['catalog_visibility'] = $product->visibility; } if (!$fields || $fields && in_array('on_sale', $field_list)) { $product_data['on_sale'] = $product->is_on_sale(); } if (!$fields || $fields && in_array('product_url', $field_list)) { $product_data['product_url'] = $product->is_type('external') ? $product->get_product_url() : ''; } if (!$fields || $fields && in_array('button_text', $field_list)) { $product_data['button_text'] = $product->is_type('external') ? $product->get_button_text() : ''; } if (!$fields || $fields && in_array('weight', $field_list)) { $product_data['weight'] = $product->get_weight() ? $product->get_weight() : null; } if (!$fields || $fields && in_array('dimensions', $field_list)) { $product_data['dimensions'] = array('length' => $product->length, 'width' => $product->width, 'height' => $product->height, 'unit' => get_option('woocommerce_dimension_unit')); } if (!$fields || $fields && in_array('shipping_required', $field_list)) { $product_data['shipping_required'] = $product->needs_shipping(); } if (!$fields || $fields && in_array('shipping_taxable', $field_list)) { $product_data['shipping_taxable'] = $product->is_shipping_taxable(); } if (!$fields || $fields && in_array('shipping_class', $field_list)) { $product_data['shipping_class'] = $product->get_shipping_class(); } if (!$fields || $fields && in_array('shipping_class_id', $field_list)) { $product_data['shipping_class_id'] = 0 !== $product->get_shipping_class_id() ? $product->get_shipping_class_id() : null; } if (!$fields || $fields && in_array('description', $field_list)) { $product_data['description'] = wpautop(do_shortcode($product->get_post_data()->post_content)); } if (!$fields || $fields && in_array('short_description', $field_list)) { $product_data['short_description'] = apply_filters('woocommerce_short_description', $product->get_post_data()->post_excerpt); } if (!$fields || $fields && in_array('reviews_allowed', $field_list)) { $product_data['reviews_allowed'] = 'open' === $product->get_post_data()->comment_status; } if (!$fields || $fields && in_array('average_rating', $field_list)) { $product_data['average_rating'] = wc_format_decimal($product->get_average_rating(), 2); } if (!$fields || $fields && in_array('rating_count', $field_list)) { $product_data['rating_count'] = (int) $product->get_rating_count(); } if (!$fields || $fields && in_array('related_ids', $field_list)) { $product_data['related_ids'] = array_map('absint', array_values($product->get_related())); } if (!$fields || $fields && in_array('upsell_ids', $field_list)) { $product_data['upsell_ids'] = array_map('absint', $product->get_upsells()); } if (!$fields || $fields && in_array('cross_sell_ids', $field_list)) { $product_data['cross_sell_ids'] = array_map('absint', $product->get_cross_sells()); } if (!$fields || $fields && in_array('parent_id', $field_list)) { $product_data['parent_id'] = $product->post->post_parent; } if (!$fields || $fields && in_array('categories', $field_list)) { $product_data['categories'] = wp_get_post_terms($product->id, 'product_cat', array('fields' => 'names')); } if (!$fields || $fields && in_array('tags', $field_list)) { $product_data['tags'] = wp_get_post_terms($product->id, 'product_tag', array('fields' => 'names')); } if (!$fields || $fields && in_array('images', $field_list)) { $product_data['images'] = $this->get_images($product); } if (!$fields || $fields && in_array('featured_src', $field_list)) { $product_data['featured_src'] = (string) wp_get_attachment_url(get_post_thumbnail_id($product->is_type('variation') ? $product->variation_id : $product->id)); } if (!$fields || $fields && in_array('attributes', $field_list)) { $product_data['attributes'] = $this->get_attributes($product); } if (!$fields || $fields && in_array('downloads', $field_list)) { $product_data['downloads'] = $this->get_downloads($product); } if (!$fields || $fields && in_array('download_limit', $field_list)) { $product_data['download_limit'] = (int) $product->download_limit; } if (!$fields || $fields && in_array('download_expiry', $field_list)) { $product_data['download_expiry'] = (int) $product->download_expiry; } if (!$fields || $fields && in_array('download_type', $field_list)) { $product_data['download_type'] = $product->download_type; } if (!$fields || $fields && in_array('purchase_note', $field_list)) { $product_data['purchase_note'] = wpautop(do_shortcode(wp_kses_post($product->purchase_note))); } if (!$fields || $fields && in_array('total_sales', $field_list)) { $product_data['total_sales'] = metadata_exists('post', $product->id, 'total_sales') ? (int) get_post_meta($product->id, 'total_sales', true) : 0; } if (!$fields || $fields && in_array('variations', $field_list)) { $product_data['variations'] = array(); } if (!$fields || $fields && in_array('parent', $field_list)) { $product_data['parent'] = array(); } if (!$fields || $fields && in_array('grouped_products', $field_list)) { $product_data['grouped_products'] = array(); } if (!$fields || $fields && in_array('menu_order', $field_list)) { $product_data['menu_order'] = $product->post->menu_order; } return $product_data; }
function TS_VCSC_WooCommerce_Ticker_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); wp_enqueue_script('ts-extend-newsticker'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-font-teammatess'); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-extend-animations'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-visual-composer-extend-front'); } extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'post_type' => 'product', 'date_format' => 'F j, Y', 'time_format' => 'l, g:i A', 'limit_posts' => 'true', 'limit_by' => 'category', 'limit_term' => '', 'filter_menu' => 'true', 'layout_menu' => 'true', 'sort_menu' => 'false', 'directions_menu' => 'false', 'filter_by' => 'category', 'ticker_direction' => 'up', 'ticker_speed' => 3000, 'ticker_break' => 480, 'ticker_border_type' => '', 'ticker_border_thick' => 1, 'ticker_border_color' => '#ededed', 'ticker_border_radius' => '', 'ticker_auto' => 'false', 'ticker_hover' => 'true', 'ticker_controls' => 'true', 'ticker_symbol' => 'false', 'ticker_icon' => '', 'ticker_paint' => '#ffffff', 'ticker_title' => 'true', 'ticker_header' => 'Latest Products', 'ticker_background' => '#D10000', 'ticker_color' => '#ffffff', 'ticker_type' => 'true', 'ticker_image' => 'true', 'ticker_price' => 'true', 'ticker_cart' => 'true', 'ticker_add_item' => 'Add This Item', 'ticker_remove_item' => 'Remove This Item', 'ticker_rating' => 'true', 'ticker_stock' => 'false', 'ticker_side' => 'left', 'ticker_fixed' => 'false', 'ticker_position' => 'top', 'ticker_adjustment' => 0, 'ticker_target' => '_parent', 'posts_limit' => 25, 'rating_maximum' => 5, 'rating_size' => 20, 'rating_quarter' => 'true', 'rating_name' => 'true', 'rating_auto' => 'true', 'rating_position' => 'top', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => 'ts-ecommerce-starfull1', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'true', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); $woo_random = mt_rand(999999, 9999999); if (!empty($el_id)) { $woo_ticker_id = $el_id; } else { $woo_ticker_id = 'ts-vcsc-woocommerce-ticker-' . $woo_random; } $output = ''; // Check for Front End Editor if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { $frontend_edit = 'true'; $ticker_fixed = 'false'; $ticker_auto = 'false'; } else { $frontend_edit = 'false'; $ticker_fixed = $ticker_fixed; $ticker_auto = $ticker_auto; } $meta_query = ''; // Recent Products if ($selection == "recent_products") { $meta_query = WC()->query->get_meta_query(); } // Featured Products if ($selection == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } // Top Rated Products if ($selection == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } // Final Query Arguments $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query); // Products on Sale if ($selection == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } // Best Selling Products if ($selection == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } // Products in Single Category if ($selection == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } // Products in Multiple Categories if ($selection == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN')); } // Start WordPress Query $loop = new WP_Query($args); if ($ticker_fixed == "true") { $newsticker_class = 'ts-newsticker-fixed'; $newsticker_position = 'ts-newsticker-' . $ticker_position; if ($ticker_position == "top") { $newsticker_style = 'top: ' . $ticker_adjustment . 'px;'; } else { $newsticker_style = 'bottom: ' . $ticker_adjustment . 'px;'; } $margin_top = 0; $margin_bottom = 0; } else { $newsticker_class = 'ts-newsticker-standard'; $newsticker_position = ''; $newsticker_style = ''; } if ($ticker_border_type != '') { $newsticker_border = 'border: ' . $ticker_border_thick . 'px ' . $ticker_border_type . ' ' . $ticker_border_color . ';'; } else { $newsticker_border = ''; } if ($ticker_side == "left") { $newsticker_elements = 'ts-newsticker-elements-left'; } else { $newsticker_elements = 'ts-newsticker-elements-right'; } if ($ticker_title == "false") { $newsticker_header = 'left: 0;'; $newsticker_controls = 'right: 10px;'; } else { $newsticker_header = ''; $newsticker_controls = ''; } if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $el_class . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Ticker_Basic', $atts); } else { $css_class = $slider_class . ' ' . $el_class; } $output .= '<div id="' . $woo_ticker_id . '" class="ts-newsticker-parent ' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . ';">'; // Create Individual Post Output $postCounter = 0; $postMonths = array(); if ($loop->have_posts()) { $output .= '<div id="ts-newsticker-oneliner-' . $woo_random . '" class="ts-newsticker-oneliner ' . $newsticker_class . ' ' . $newsticker_position . ' ' . $ticker_border_radius . '" style="' . $newsticker_style . ' ' . $newsticker_border . '" data-ticker="ts-newsticker-ticker-' . $woo_random . '" data-controls="ts-newsticker-controls-' . $woo_random . '" data-navigation="' . $ticker_controls . '" data-break="' . $ticker_break . '" data-auto="' . $ticker_auto . '" data-speed="' . $ticker_speed . '" data-hover="' . $ticker_hover . '" data-direction="' . $ticker_direction . '" data-parent="' . $woo_ticker_id . '" data-side="' . $ticker_side . '" data-header="ts-newsticker-header-' . $woo_random . '" data-next="ts-newsticker-controls-next-' . $woo_random . '" data-prev="ts-newsticker-controls-prev-' . $woo_random . '" data-play="ts-newsticker-controls-play-' . $woo_random . '" data-stop="ts-newsticker-controls-stop-' . $woo_random . '">'; $output .= '<div class="ts-newsticker-elements-frame ' . $newsticker_elements . ' ' . $ticker_border_radius . '" style="">'; // Add Navigation Controls $output .= '<div id="ts-newsticker-controls-' . $woo_random . '" class="ts-newsticker-controls" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . ' ' . $newsticker_controls . '">'; $output .= '<div id="ts-newsticker-controls-next-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>'; $output .= '<div id="ts-newsticker-controls-prev-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>'; $output .= '<div id="ts-newsticker-controls-stop-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: block;" : "display: none;") . '"><span class="ts-ecommerce-pause"></span></div>'; $output .= '<div id="ts-newsticker-controls-play-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: none;" : "display: block;") . '"><span class="ts-ecommerce-play"></span></div>'; $output .= '</div>'; if ($ticker_side == "left" && $ticker_title == "true") { $output .= '<div id="ts-newsticker-header-' . $woo_random . '" class="header ' . $ticker_border_radius . '" style="background: ' . $ticker_background . '; color: ' . $ticker_color . '; left: 0;">'; if ($ticker_icon != '' && $ticker_icon != 'transparent' && $ticker_symbol == "true") { $output .= '<i class="ts-font-icon ' . $ticker_icon . '" style="color: ' . $ticker_paint . '"></i>'; } $output .= '<span>' . $ticker_header . '</span>'; $output .= '</div>'; } $output .= '<ul id="ts-newsticker-ticker-' . $woo_random . '" class="newsticker ' . $ticker_border_radius . '" style="' . $newsticker_header . '">'; while ($loop->have_posts()) { $loop->the_post(); $postCounter++; if ($postCounter < $posts_limit + 1) { $postAttributes = 'data-full="' . get_post_time($date_format) . '" data-time="' . get_post_time($time_format) . '" data-author="' . get_the_author() . '" data-date="' . get_post_time('U') . '" data-modified="' . get_the_modified_time('U') . '" data-title="' . get_the_title() . '" data-comments="' . get_comments_number() . '" data-id="' . get_the_ID() . '"'; $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; $onsale = $product->is_on_sale() ? 'true' : 'false'; // Rating Settings $rating_html = $product->get_rating_html(); $rating = $product->get_average_rating(); if ($rating == '') { $rating = 0; } if ($rating_quarter == "true") { $rating_value = floor($rating * 4) / 4; } else { $rating_value = $rating; } $rating_value = number_format($rating_value, 2, $caption_digits, ''); if ($rating_rtl == "false") { $rating_width = $rating_value / $rating_maximum * 100; } else { $rating_width = 100 - $rating_value / $rating_maximum * 100; } if ($rating_symbol == "other") { if ($rating_icon == "ts-ecommerce-starfull1") { $rating_class = 'ts-rating-stars-star1'; } else { if ($rating_icon == "ts-ecommerce-starfull2") { $rating_class = 'ts-rating-stars-star2'; } else { if ($rating_icon == "ts-ecommerce-starfull3") { $rating_class = 'ts-rating-stars-star3'; } else { if ($rating_icon == "ts-ecommerce-starfull4") { $rating_class = 'ts-rating-stars-star4'; } else { if ($rating_icon == "ts-ecommerce-heartfull") { $rating_class = 'ts-rating-stars-heart1'; } else { if ($rating_icon == "ts-ecommerce-heart") { $rating_class = 'ts-rating-stars-heart2'; } else { if ($rating_icon == "ts-ecommerce-thumbsup") { $rating_class = 'ts-rating-stars-thumb'; } else { if ($rating_icon == "ts-ecommerce-ribbon4") { $rating_class = 'ts-rating-stars-ribbon'; } } } } } } } } } else { $rating_class = 'ts-rating-stars-smile'; } if ($rating_value >= 0 && $rating_value <= 1) { $caption_class = 'ts-label-danger'; $caption_background = 'background-color: ' . $caption_danger . ';'; } else { if ($rating_value > 1 && $rating_value <= 2) { $caption_class = 'ts-label-warning'; $caption_background = 'background-color: ' . $caption_warning . ';'; } else { if ($rating_value > 2 && $rating_value <= 3) { $caption_class = 'ts-label-info'; $caption_background = 'background-color: ' . $caption_info . ';'; } else { if ($rating_value > 3 && $rating_value <= 4) { $caption_class = 'ts-label-primary'; $caption_background = 'background-color: ' . $caption_primary . ';'; } else { if ($rating_value > 4 && $rating_value <= 5) { $caption_class = 'ts-label-success'; $caption_background = 'background-color: ' . $caption_success . ';'; } } } } } // Check if Product already in Cart $cart_page_id = wc_get_page_id('cart'); $already_added = "false"; foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) { if ($product_id == $cart_item['product_id']) { $already_added = "true"; $cart_link = apply_filters('woocommerce_cart_item_remove_link', sprintf('<a class="ts-newsticker-product-remove" href="%s" title="%s" rel="" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-newsticker-product-cart ts-woocommerce-product-cart ts-ecommerce-cross2"></i></a>', esc_url($woocommerce->cart->get_remove_url($cart_item_key)), $ticker_remove_item), $cart_item_key); } } if ($already_added == "false") { $cart_link = '<span class="ts-woocommerce-link-wrapper"><a class="ts-newsticker-product-purchase" href="?add-to-cart=' . $product_id . '" title="' . $ticker_add_item . '" rel="" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-newsticker-product-cart ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a></span>'; } $output .= '<li ' . $postAttributes . '>'; if ($ticker_image == 'true') { if ('' != get_the_post_thumbnail()) { $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $output .= '<img class="ts-newsticker-image" src="' . $thumbnail[0] . '" style="">'; } } $output .= '<span class="ts-woocommerce-link-wrapper"><a href="' . get_permalink() . '" target="' . $ticker_target . '">'; $output .= get_the_title(); $output .= '</a></span>'; // Product Price if ($ticker_price == "true") { $output .= '<span class="ts-newsticker-pricetag" style="">'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $output .= '<span class="ts-newsticker-product-regular" style="float: none;"><del>' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </span><span class="ts-newsticker-product-special" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>'; } else { $output .= '<span class="ts-newsticker-product-current" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>'; } } else { $to = $product->price; $output .= '<span class="ts-newsticker-product-current" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>'; } } else { $to = $product->price; $output .= '<span class="ts-newsticker-product-current" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>'; } $output .= '</span>'; } // Sale Ribbon if ($onsale == "true") { $output .= '<i style="position: inherit" class="ts-newsticker-product-sale ts-woocommerce-product-sale ts-ecommerce-tagsale"></i>'; } // Product Rating if ($ticker_rating == "true") { $output .= '<span class="ts-rating-stars-frame" data-auto="false" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 10px 0 0 10px; float: none;">'; $output .= '<span class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $output .= '<span class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</span>'; } $output .= '<span class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $output .= '<span class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></span>'; $output .= '</span>'; if ($caption_show == "true" && $caption_position == "right") { $output .= '<span class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</span>'; } $output .= '</span>'; $output .= '</span>'; } // Add to Cart Icon if ($ticker_cart == "true") { //$output .= '<a class="ts-newsticker-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-newsticker-product-cart ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; $output .= $cart_link; } // Product In-Stock or Unavailable if ($ticker_stock == "true") { $output .= '<span class="ts-woocommerce-product-status" style="margin-left: 10px;">'; if ($stock == 'false') { $output .= '<span class="ts-woocommerce-product-stock" style="position: inherit;"><span class="ts-woocommerce-product-outofstock">' . __('Out of Stock', 'woocommerce') . '</span></span>'; } else { if ($stock == 'true') { $output .= '<span class="ts-woocommerce-product-stock" style="position: inherit;"><span class="ts-woocommerce-product-instock">' . __('In Stock', 'woocommerce') . '</span></span>'; } } $output .= '</span>'; } $output .= '</li>'; } } $output .= '</ul>'; if ($ticker_side == "right" && $ticker_title == "true") { $output .= '<div id="ts-newsticker-header-' . $woo_random . '" class="header ' . $ticker_border_radius . '" style="background: ' . $ticker_background . '; color: ' . $ticker_color . '; right: 0;">'; if ($ticker_icon != '' && $ticker_icon != 'transparent' && $ticker_symbol == "true") { $output .= '<i class="ts-font-icon ' . $ticker_icon . '" style="color: ' . $ticker_paint . '"></i>'; } $output .= '<span>' . $ticker_header . '</span>'; $output .= '</div>'; } $output .= '</div>'; $output .= '</div>'; } else { echo __("No products could be found.", "ts_visual_composer_extend"); } $output .= '</div>'; wp_reset_postdata(); wp_reset_query(); echo $output; $myvariable = ob_get_clean(); return $myvariable; }
function is_on_sale() { if ($this->per_product_pricing_active && !empty($this->bundled_item_ids)) { $is_on_sale = false; foreach ($this->bundled_item_ids as $bundled_item_id) { // remove suffix $sep = explode('_', $bundled_item_id); $product_id = $sep[0]; if ($this->is_wc_v2) { $bundled_product = get_product($product_id); } else { $bundled_product = new WC_Product($product_id); } if ($bundled_product->is_on_sale()) { $is_on_sale = true; break; } } return $is_on_sale; } else { if ($this->sale_price && $this->sale_price == $this->price) { return true; } } }
/** * Gets an individual ticket * * @param $event_id * @param $ticket_id * * @return null|Tribe__Tickets__Ticket_Object */ public function get_ticket($event_id, $ticket_id) { if (class_exists('WC_Product_Simple')) { $product = new WC_Product_Simple($ticket_id); } else { $product = new WC_Product($ticket_id); } if (!$product) { return null; } $return = new Tribe__Tickets__Ticket_Object(); $product_data = $product->get_post_data(); $qty = get_post_meta($ticket_id, 'total_sales', true); $return->description = $product_data->post_excerpt; $return->frontend_link = get_permalink($ticket_id); $return->ID = $ticket_id; $return->name = $product->get_title(); $return->price = $product->get_price(); $return->regular_price = $product->get_regular_price(); $return->on_sale = (bool) $product->is_on_sale(); $return->provider_class = get_class($this); $return->admin_link = admin_url(sprintf(get_post_type_object($product_data->post_type)->_edit_link . '&action=edit', $ticket_id)); $return->start_date = get_post_meta($ticket_id, '_ticket_start_date', true); $return->end_date = get_post_meta($ticket_id, '_ticket_end_date', true); $return->purchase_limit = get_post_meta($ticket_id, '_ticket_purchase_limit', true); $complete_totals = $this->count_order_items_by_status($ticket_id, 'complete'); $pending_totals = $this->count_order_items_by_status($ticket_id, 'incomplete'); $qty = $qty ? $qty : 0; $pending = $pending_totals['total'] ? $pending_totals['total'] : 0; // Ticket stock is a simple reflection of remaining inventory for this item... $stock = $product->get_stock_quantity(); // ...With some exceptions for global stock tickets $stock = $this->set_stock_level_for_global_stock_tickets($stock, $event_id, $ticket_id); $return->manage_stock($product->managing_stock()); $return->stock($stock); $return->global_stock_mode(get_post_meta($ticket_id, '_global_stock_mode', true)); $return->global_stock_cap(get_post_meta($ticket_id, '_global_stock_cap', true)); $return->qty_sold($qty); $return->qty_pending($pending); $return->qty_cancelled($this->get_cancelled($ticket_id)); if (empty($return->purchase_limit) && 0 !== (int) $return->purchase_limit) { /** * Filter the default purchase limit for the ticket * * @var int * * @return int */ $return->purchase_limit = apply_filters('tribe_tickets_default_purchase_limit', 0); } return apply_filters('wootickets_get_ticket', $return, $event_id, $ticket_id); }
/** * Converts a product or variation prices to the specific currency, taking * into account manually entered prices. * * @param WC_Product product The product whose prices should be converted. * @param string currency A currency code. * @param array product_regular_prices_in_currency An array of manually entered * product prices (one for each currency). * @param array product_sale_prices_in_currency An array of manually entered * product prices (one for each currency). * @return WC_Product */ protected function convert_to_currency(WC_Product $product, $currency, array $product_regular_prices_in_currency, array $product_sale_prices_in_currency) { // The determination of "is on sale" is done using values of product's // prices. To ensure that the logic is not broken, such evaluation should be // performed before any conversion $product_is_on_sale = $product->is_on_sale(); $product->regular_price = get_value($currency, $product_regular_prices_in_currency, $this->convert_from_base($product->regular_price, $currency)); $product->sale_price = get_value($currency, $product_sale_prices_in_currency, $this->convert_from_base($product->sale_price, $currency)); if (!is_numeric($product->regular_price) || $product_is_on_sale && $product->sale_price < $product->regular_price) { $product->price = $product->sale_price; } else { $product->price = $product->regular_price; } return $product; }
/** * True if a one of the composited products has a component discount, or if there is a base sale price defined. * * @return boolean */ public function is_on_sale() { if ($this->is_priced_per_product()) { if (!$this->is_synced()) { $this->sync_composite(); } $composite_on_sale = $this->base_sale_price != $this->base_regular_price && $this->base_sale_price == $this->base_price || $this->has_discounts && $this->min_composite_regular_price > 0; } else { $composite_on_sale = parent::is_on_sale(); } return apply_filters('woocommerce_composite_on_sale', $composite_on_sale, $this); }
function woo_products_2_func($atts, $content = null) { extract(shortcode_atts(array('animation' => '', 'animation_delay' => '', 'animation_delay_item' => '', 'animation_iteration' => '', 'orderby' => '', 'limit' => '', 'show' => '', 'order' => ''), $atts)); if (!class_exists('woocommerce')) { return ''; } ob_start(); global $post; $query_args = array('posts_per_page' => $limit, 'post_status' => 'publish', 'post_type' => 'product', 'no_found_rows' => 1, 'order' => $order == 'asc' ? 'asc' : 'desc'); $query_args['meta_query'] = array(); $query_args['meta_query'][] = WC()->query->stock_status_meta_query(); $query_args['meta_query'] = array_filter($query_args['meta_query']); switch ($show) { case 'featured': $query_args['meta_query'][] = array('key' => '_featured', 'value' => 'yes'); break; case 'onsale': $product_ids_on_sale = wc_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $query_args['post__in'] = $product_ids_on_sale; break; } switch ($orderby) { case 'price': $query_args['meta_key'] = '_price'; $query_args['orderby'] = 'meta_value_num'; break; case 'rand': $query_args['orderby'] = 'rand'; break; case 'sales': $query_args['meta_key'] = 'total_sales'; $query_args['orderby'] = 'meta_value_num'; break; default: $query_args['orderby'] = 'date'; } $current_animation_delay = $animation_delay; ?> <div class="bottom-padding"> <div class="row text-center"> <?php $j = 1; $k = 1; $loop = new WP_Query($query_args); if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); $temp = 1; $product = new WC_Product(get_the_ID()); ?> <div class="col-sm-3 col-md-3 product product-centered <?php echo ts_get_animation_class($animation); ?> " <?php echo ts_get_animation_data_class($current_animation_delay, $animation_iteration); ?> > <div class="default"> <?php if ($product->is_on_sale()) { ?> <?php echo apply_filters('woocommerce_sale_flash', '<span class="sale-custome"></span>', $post, $product); ?> <?php } ?> <a href="<?php echo esc_url(get_the_permalink()); ?> " class="product-image"> <img src="<?php echo esc_url(get_xv_thumbnail(270, 270)); ?> " /> </a> <div class="actions not-rotation-actions"> <?php wc_get_template('/loop/add-to-cart.php'); ?> <?php if (class_exists('YITH_WCWL')) { echo do_shortcode('[yith_wcwl_add_to_wishlist]'); } ?> <a href="<?php echo esc_url(get_the_permalink()); ?> " class="add-compare"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="16px" height="16px" viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve"> <path fill="#1e1e1e" d="M16,3.063L13,0v2H1C0.447,2,0,2.447,0,3s0.447,1,1,1h12v2L16,3.063z"></path> <path fill="#1e1e1e" d="M16,13.063L13,10v2H1c-0.553,0-1,0.447-1,1s0.447,1,1,1h12v2L16,13.063z"></path> <path fill="#1e1e1e" d="M15,7H3V5L0,7.938L3,11V9h12c0.553,0,1-0.447,1-1S15.553,7,15,7z"></path> </svg> </a> </div> <div class="product-description"> <div class="vertical"> <h3 class="product-name"> <a href="<?php echo esc_url(get_the_permalink()); ?> "><?php the_title(); ?> </a> </h3> <div class="price"><?php echo $product->get_price_html(); ?> </div> </div> </div> </div> </div><!-- .product --> <?php $current_animation_delay += $animation_delay_item; $k++; } } else { echo __('No products found', 'progressive'); } wp_reset_postdata(); ?> </div> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
/** * Gets an individual ticket * * @param $unused_event_id * @param $ticket_id * * @return null|Tribe__Events__Tickets__Ticket_Object */ public function get_ticket($unused_event_id, $ticket_id) { if (class_exists('WC_Product_Simple')) { $product = new WC_Product_Simple($ticket_id); } else { $product = new WC_Product($ticket_id); } if (!$product) { return null; } $return = new Tribe__Events__Tickets__Ticket_Object(); $product_data = $product->get_post_data(); $qty = get_post_meta($ticket_id, 'total_sales', true); $return->description = $product_data->post_excerpt; $return->frontend_link = get_permalink($ticket_id); $return->ID = $ticket_id; $return->name = $product->get_title(); $return->price = $product->get_price(); $return->regular_price = $product->get_regular_price(); $return->on_sale = (bool) $product->is_on_sale(); $return->provider_class = get_class($this); $return->admin_link = admin_url(sprintf(get_post_type_object($product_data->post_type)->_edit_link . '&action=edit', $ticket_id)); $return->stock = $product->get_stock_quantity(); $return->start_date = get_post_meta($ticket_id, '_ticket_start_date', true); $return->end_date = get_post_meta($ticket_id, '_ticket_end_date', true); $return->qty_sold = $qty ? $qty : 0; $return->qty_pending = $qty ? $this->count_incomplete_order_items($ticket_id) : 0; return $return; }
function WooComposer_Single_style03($atts) { $product_id = $product_style = $display_elements = $img_animate = $text_align = $color_heading = $color_categories = $color_price = ''; $color_rating = $color_rating_bg = $color_quick_bg = $color_quick = $color_cart_bg = $color_cart = $color_product_desc = ''; $color_product_desc_bg = $size_title = $size_cat = $size_price = $color_on_sale = $color_on_sale_bg = $label_on_sale = $border_style = ''; $border_color = $border_size = $border_radius = $sale_price = $on_sale_alignment = $on_sale_style = $product_img_disp = ''; extract(shortcode_atts(array("product_id" => "", "product_style" => "style01", "display_elements" => "", "label_on_sale" => "Sale!", "text_align" => "left", "img_animate" => "rotate-clock", "color_heading" => "", "color_categories" => "", "color_price" => "", "color_rating" => "", "color_rating_bg" => "", "color_quick_bg" => "", "color_quick" => "", "color_cart_bg" => "", "color_on_sale_bg" => "", "color_on_sale" => "", "color_cart" => "", "color_product_desc" => "", "color_product_desc_bg" => "", "size_title" => "", "size_cat" => "", "size_price" => "", "border_style" => "", "border_color" => "", "border_size" => "", "border_radius" => "", "sale_price" => "", "on_sale_style" => "wcmp-sale-circle", "on_sale_alignment" => "wcmp-sale-right", "product_img_disp" => "single"), $atts)); $output = $heading_style = $cat_style = $price_style = $cart_style = $cart_bg_style = $view_style = $view_bg_style = $rating_style = ''; $desc_style = $label_style = $border = $desc_style = $sale_price_size = ''; $image_size = apply_filters('single_product_large_thumbnail_size', 'shop_single'); if ($sale_price !== '') { $sale_price_size = 'font-size:' . $sale_price . 'px;'; } $img_animate = 'wcmp-img-' . $img_animate; if ($border_style !== '') { $border .= 'border:' . $border_size . 'px ' . $border_style . ' ' . $border_color . ';'; $border .= 'border-radius:' . $border_radius . 'px;'; } if ($color_product_desc_bg !== '') { $desc_style .= 'background:' . $color_product_desc_bg . ';'; } if ($color_product_desc !== '') { $desc_style .= 'color:' . $color_product_desc . ';'; } if ($color_heading !== "") { $heading_style = 'color:' . $color_heading . ';'; } if ($size_title !== "") { $heading_style .= 'font-size:' . $size_title . 'px;'; } if ($color_categories !== "") { $cat_style = 'color:' . $color_categories . ';'; } if ($size_cat !== "") { $cat_style .= 'font-size:' . $size_cat . 'px;'; } if ($color_price !== "") { $price_style = 'color:' . $color_price . ';'; } if ($size_price !== "") { $price_style .= 'font-size:' . $size_price . 'px;'; } if ($color_rating !== "") { $rating_style .= 'color:' . $color_rating . ';'; } if ($color_rating_bg !== "") { $rating_style .= 'background:' . $color_rating_bg . ';'; } if ($color_quick_bg !== "") { $view_bg_style = 'background:' . $color_quick_bg . ';'; } if ($color_quick !== "") { $view_style = 'color:' . $color_quick . ';'; } if ($color_cart_bg !== "") { $cart_bg_style = 'background:' . $color_cart_bg . ';'; } if ($color_cart !== "") { $cart_style = 'color:' . $color_cart . ';'; } if ($color_on_sale_bg !== "") { $label_style = 'background:' . $color_on_sale_bg . ';'; } if ($color_on_sale !== "") { $label_style .= 'color:' . $color_on_sale . ';'; } $elemets = explode(",", $display_elements); $product_title = get_the_title($product_id); $post = get_post($product_id); $product_desc = get_post($product_id)->post_excerpt; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $rating = $product->get_rating_html(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'InStock' : 'OutOfStock'; if ($product->is_on_sale()) { $on_sale = apply_filters('woocommerce_sale_flash', $label_on_sale, $post, $product); } else { $on_sale = ''; } $cat_count = sizeof(get_the_terms($product_id, 'product_cat')); $tag_count = sizeof(get_the_terms($product_id, 'product_tag')); $categories = $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>'); $tags = $product->get_tags(', ', '<span class="tagged_as">' . _n('', '', $tag_count, 'woocommerce') . ' ', '.</span>'); $output .= "\n" . '<div class="wcmp-product woocommerce wcmp-' . $product_style . ' ' . $img_animate . '" style="' . $border . ' ' . $desc_style . '">'; $output .= "\n\t" . '<div class="wcmp-product-image">'; if (!empty($attachment_ids) && count($attachment_ids) > 1 && $product_img_disp == "carousel") { $uniqid = uniqid(); $output .= '<div class="wcmp-single-image-carousel">'; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $src = $product_img[0]; $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; foreach ($attachment_ids as $attachment_id) { $product_img = wp_get_attachment_image_src($attachment_id, $image_size); $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; } $output .= '</div>'; } else { $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $src = $product_img[0]; $output .= '<a href="' . get_permalink($product_id) . '"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></a>'; } if ($on_sale !== '') { $output .= "\n" . '<div class="wcmp-onsale ' . $on_sale_alignment . ' ' . $on_sale_style . '"><span class="onsale" style="' . $label_style . ' ' . $sale_price_size . '">' . $on_sale . '</span></div>'; } if ($stock == 'OutOfStock') { $output .= "\n" . '<span class="wcmp-out-stock">' . __('Out Of Stock!', 'woocomposer') . '</span>'; } $output .= '</div>'; $output .= "\n\t" . '<div class="wcmp-product-desc">'; $output .= '<a href="' . get_permalink($product_id) . '">'; $output .= "\n\t\t" . '<h2 style="' . $heading_style . '">' . $product_title . '</h2>'; $output .= '</a>'; if (in_array("category", $elemets)) { $output .= '<h5 style="' . $cat_style . '">'; if ($categories !== '') { $output .= $categories; $output .= $tags; } $output .= '</h5>'; } $output .= "\n\t\t" . '<div class="wcmp-price"><span class="price" style="' . $price_style . '">' . $price . '</span></div>'; $output .= '<div class="wcmp-style3-cart-block">'; /*Class Start wcmp-style3-cart-block*/ $output .= '<div class="wcmp-add-to-cart" style="' . $cart_bg_style . '"><a style="' . $cart_style . '" title="Add to Cart" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-product_id="' . $product_id . '" data-product_sku="" class="button add_to_cart_button product_type_simple">Add to Cart</a></div>'; if (in_array("reviews", $elemets)) { $output .= "\n" . '<div class="wcmp-star-ratings" style="' . $rating_style . '">' . $rating . '</div>'; } if (in_array("quick", $elemets)) { $output .= '<div class="wcmp-quick-view quick-view-single" style="' . $view_bg_style . '"><a style="' . $view_style . '" title="Quick View" href="' . get_permalink($product_id) . '"><i class="wooicon-plus32"></i></a></div>'; } $output .= '</div>'; /*Class End wcmp-style3-cart-block*/ if (in_array("description", $elemets)) { $output .= "\n\t\t" . '<div class="wcmp-product-content" style="' . $desc_style . '">' . $product_desc . '</div>'; } if (in_array("quick", $elemets)) { $query = new WP_Query(array('post_type' => 'product', 'post__in' => array($product_id))); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $output .= '<div class="wcmp-quick-view-wrapper">'; $output .= '<div class="wcmp-quick-view-wrapper woocommerce">'; $output .= '<div class="wcmp-close-single"><i class="wooicon-cross2"></i></div>'; if (!empty($attachment_ids) && count($attachment_ids) > 1) { $uniqid = uniqid(); $output .= '<div class="wcmp-image-carousel wcmp-carousel-' . $uniqid . '" data-class="wcmp-carousel-' . $uniqid . '">'; foreach ($attachment_ids as $attachment_id) { $product_img = wp_get_attachment_image_src($attachment_id, $image_size); $output .= '<div><div class="wcmp-image"><img src="' . $product_img[0] . '"/></div></div>'; } $output .= '</div>'; } else { $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $output .= '<div class="wcmp-single-image"><img src="' . $product_img[0] . '"/></div>'; } $output .= '<div class="wcmp-product-content-single">'; ob_start(); do_action('woocommerce_single_product_summary'); $output .= ob_get_clean(); $output .= '</div>'; $output .= '<div class="clear"></div>'; $output .= '</div>'; $output .= '</div>'; } } } $output .= "\n\t" . '</div>'; $output .= "\n\t" . '</div>'; return $output; }
/** * Get standard product data that applies to every product type * * @since 2.1 * @param WC_Product $product * @return WC_Product */ private function get_product_data($product) { return array('title' => $product->get_title(), 'id' => (int) $product->is_type('variation') ? $product->get_variation_id() : $product->id, 'created_at' => $this->server->format_datetime($product->get_post_data()->post_date_gmt), 'updated_at' => $this->server->format_datetime($product->get_post_data()->post_modified_gmt), 'type' => $product->product_type, 'status' => $product->get_post_data()->post_status, 'downloadable' => $product->is_downloadable(), 'virtual' => $product->is_virtual(), 'permalink' => $product->get_permalink(), 'sku' => $product->get_sku(), 'price' => $product->get_price(), 'regular_price' => $product->get_regular_price(), 'sale_price' => $product->get_sale_price() ? $product->get_sale_price() : null, 'price_html' => $product->get_price_html(), 'taxable' => $product->is_taxable(), 'tax_status' => $product->get_tax_status(), 'tax_class' => $product->get_tax_class(), 'managing_stock' => $product->managing_stock(), 'stock_quantity' => $product->get_stock_quantity(), 'in_stock' => $product->is_in_stock(), 'backorders_allowed' => $product->backorders_allowed(), 'backordered' => $product->is_on_backorder(), 'sold_individually' => $product->is_sold_individually(), 'purchaseable' => $product->is_purchasable(), 'featured' => $product->is_featured(), 'visible' => $product->is_visible(), 'catalog_visibility' => $product->visibility, 'on_sale' => $product->is_on_sale(), 'product_url' => $product->is_type('external') ? $product->get_product_url() : '', 'button_text' => $product->is_type('external') ? $product->get_button_text() : '', 'weight' => $product->get_weight() ? $product->get_weight() : null, 'dimensions' => array('length' => $product->length, 'width' => $product->width, 'height' => $product->height, 'unit' => get_option('woocommerce_dimension_unit')), 'shipping_required' => $product->needs_shipping(), 'shipping_taxable' => $product->is_shipping_taxable(), 'shipping_class' => $product->get_shipping_class(), 'shipping_class_id' => 0 !== $product->get_shipping_class_id() ? $product->get_shipping_class_id() : null, 'description' => wpautop(do_shortcode($product->get_post_data()->post_content)), 'short_description' => apply_filters('woocommerce_short_description', $product->get_post_data()->post_excerpt), 'reviews_allowed' => 'open' === $product->get_post_data()->comment_status, 'average_rating' => wc_format_decimal($product->get_average_rating(), 2), 'rating_count' => (int) $product->get_rating_count(), 'related_ids' => array_map('absint', array_values($product->get_related())), 'upsell_ids' => array_map('absint', $product->get_upsells()), 'cross_sell_ids' => array_map('absint', $product->get_cross_sells()), 'parent_id' => $product->post->post_parent, 'categories' => wp_get_post_terms($product->id, 'product_cat', array('fields' => 'names')), 'tags' => wp_get_post_terms($product->id, 'product_tag', array('fields' => 'names')), 'images' => $this->get_images($product), 'featured_src' => (string) wp_get_attachment_url(get_post_thumbnail_id($product->is_type('variation') ? $product->variation_id : $product->id)), 'attributes' => $this->get_attributes($product), 'downloads' => $this->get_downloads($product), 'download_limit' => (int) $product->download_limit, 'download_expiry' => (int) $product->download_expiry, 'download_type' => $product->download_type, 'purchase_note' => wpautop(do_shortcode(wp_kses_post($product->purchase_note))), 'total_sales' => metadata_exists('post', $product->id, 'total_sales') ? (int) get_post_meta($product->id, 'total_sales', true) : 0, 'variations' => array(), 'parent' => array(), 'grouped_products' => array()); }
function TS_VCSC_WooCommerce_Rating_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-extend-simptip'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-visual-composer-extend-front'); } extract(shortcode_atts(array('best_rated' => 'false', 'id' => '', 'rating_maximum' => 5, 'rating_size' => 24, 'rating_quarter' => 'true', 'rating_title' => 'true', 'rating_auto' => 'true', 'rating_position' => 'top', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => '', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'true', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'title_size' => 24, 'title_truncate' => 'true', 'use_name' => 'true', 'custom_title' => '', 'show_cart' => 'true', 'cart_color' => '#cccccc', 'show_link' => 'true', 'link_color' => '#cccccc', 'tooltip_css' => 'false', 'tooltip_content' => '', 'tooltip_position' => 'ts-simptip-position-top', 'tooltip_style' => '', 'margin_top' => 20, 'margin_bottom' => 20, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); // Final Query Arguments add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => -1, 'orderby' => 'date', 'order' => 'desc', 'paged' => 1, 'meta_query' => $meta_query); $loop = new WP_Query($args); if ($loop->have_posts()) { $best_rating = 0; while ($loop->have_posts()) { $loop->the_post(); $product_id = get_the_ID(); $product = new WC_Product($product_id); if ($product_id == $id) { $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; $onsale = $product->is_on_sale() ? 'true' : 'false'; $link = get_permalink(); // Rating Settings $rating_html = $product->get_rating_html(); $rating = $product->get_average_rating(); if ($rating == '') { $rating = 0; } if ($rating_quarter == "true") { $rating_value = floor($rating * 4) / 4; } else { $rating_value = $rating; } $rating_value = number_format($rating_value, 2, $caption_digits, ''); break; } } } wp_reset_postdata(); wp_reset_query(); if ($rating_title == "true") { if ($use_name == "true") { $rating_title = $product_title; } else { $rating_title = $custom_title; } } else { $rating_title = ''; } if ($rating_rtl == "false") { $rating_width = $rating_value / $rating_maximum * 100; } else { $rating_width = 100 - $rating_value / $rating_maximum * 100; } if ($rating_symbol == "other") { if ($rating_icon == "ts-ecommerce-starfull1") { $rating_class = 'ts-rating-stars-star1'; } else { if ($rating_icon == "ts-ecommerce-starfull2") { $rating_class = 'ts-rating-stars-star2'; } else { if ($rating_icon == "ts-ecommerce-starfull3") { $rating_class = 'ts-rating-stars-star3'; } else { if ($rating_icon == "ts-ecommerce-starfull4") { $rating_class = 'ts-rating-stars-star4'; } else { if ($rating_icon == "ts-ecommerce-heartfull") { $rating_class = 'ts-rating-stars-heart1'; } else { if ($rating_icon == "ts-ecommerce-heart") { $rating_class = 'ts-rating-stars-heart2'; } else { if ($rating_icon == "ts-ecommerce-thumbsup") { $rating_class = 'ts-rating-stars-thumb'; } else { if ($rating_icon == "ts-ecommerce-ribbon4") { $rating_class = 'ts-rating-stars-ribbon'; } } } } } } } } } else { $rating_class = 'ts-rating-stars-smile'; } if ($rating_value >= 0 && $rating_value <= 1) { $caption_class = 'ts-label-danger'; $caption_background = 'background-color: ' . $caption_danger . ';'; } else { if ($rating_value > 1 && $rating_value <= 2) { $caption_class = 'ts-label-warning'; $caption_background = 'background-color: ' . $caption_warning . ';'; } else { if ($rating_value > 2 && $rating_value <= 3) { $caption_class = 'ts-label-info'; $caption_background = 'background-color: ' . $caption_info . ';'; } else { if ($rating_value > 3 && $rating_value <= 4) { $caption_class = 'ts-label-primary'; $caption_background = 'background-color: ' . $caption_primary . ';'; } else { if ($rating_value > 4 && $rating_value <= 5) { $caption_class = 'ts-label-success'; $caption_background = 'background-color: ' . $caption_success . ';'; } } } } } // Line Height Adjustment if ($show_cart == "true" || $show_link == "true") { if ($title_size > 24) { $line_height = $title_size; } else { $line_height = 24; } } else { $line_height = $title_size; } // Tooltip if ($tooltip_css == "true") { if (strlen($tooltip_content) != 0) { $rating_tooltipclasses = " ts-simptip-multiline " . $tooltip_style . " " . $tooltip_position; $rating_tooltipcontent = ' data-tstooltip="' . $tooltip_content . '"'; } else { $rating_tooltipclasses = ""; $rating_tooltipcontent = ""; } } else { $rating_tooltipclasses = ""; if (strlen($tooltip_content) != 0) { $rating_tooltipcontent = ' title="' . $tooltip_content . '"'; } else { $rating_tooltipcontent = ""; } } if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Rating_Basic', $atts); } else { $css_class = ''; } $output = ''; $output .= '<div class="ts-rating-stars-frame ' . $el_class . ' ' . $css_class . '" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px;">'; if ($rating_position == 'top' && $rating_title != '') { $output .= '<div class="ts-rating-title ts-rating-title-top ' . ($title_truncate == "true" ? " ts-truncated" : "") . '" style="font-size: ' . $title_size . 'px; line-height: ' . $line_height . 'px; vertical-align: middle;">'; if ($show_cart == "true") { $output .= '<a style="position: inherit; margin-right: 10px;" class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="color: ' . $cart_color . '" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; } if ($show_link == "true") { $output .= '<a style="position: inherit; margin-right: 10px;" href="' . $link . '" class="ts-woocommerce-product-link"><i style="color: ' . $link_color . '" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a>'; } $output .= $rating_title; $output .= '</div>'; } if ($rating_tooltipcontent != '') { $output .= '<div class="ts-rating-tooltip ' . $rating_tooltipclasses . '" ' . $rating_tooltipcontent . '>'; } $output .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $output .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $output .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $output .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $output .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '</div>'; if ($rating_tooltipcontent != '') { $output .= '</div>'; } if ($rating_position == 'bottom' && $rating_title != '') { $output .= '<div class="ts-rating-title ts-rating-title-bottom ' . ($title_truncate == "true" ? " ts-truncated" : "") . '" style="font-size: ' . $title_size . 'px; line-height: ' . $line_height . 'px; vertical-align: middle;">'; if ($show_cart == "true") { $output .= '<a style="position: inherit; margin-left: 10px;" class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="color: ' . $cart_color . '" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; } if ($show_link == "true") { $output .= '<a style="position: inherit; margin-left: 10px;" href="' . $link . '" class="ts-woocommerce-product-link"><i style="color: ' . $link_color . '" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a>'; } $output .= $rating_title; $output .= '</div>'; } $output .= '</div>'; echo $output; $myvariable = ob_get_clean(); return $myvariable; }