get_average_rating() публичный Метод

Get average rating.
public get_average_rating ( string $context = 'view' ) : float
$context string
Результат float
 /**
  * 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());
 }
 /**
  * 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_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;
 }
 /**
  * Update a products average rating meta.
  *
  * @since 2.7.0
  * @param WC_Product $product
  */
 public function update_average_rating($product)
 {
     update_post_meta($product->get_id(), '_wc_average_rating', $product->get_average_rating('edit'));
 }
 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;
 }
Пример #7
0
/**
 * Products slider on single page product
 * @since  1.0.0
 */
function shop_isle_products_slider_on_single_page()
{
    global $wp_customize;
    $shop_isle_products_slider_single_hide = get_theme_mod('shop_isle_products_slider_single_hide');
    if (isset($shop_isle_products_slider_single_hide) && $shop_isle_products_slider_single_hide != 1) {
        echo '<hr class="divider-w">';
        echo '<section class="module module-small-bottom aya">';
    } elseif (isset($wp_customize)) {
        echo '<hr class="divider-w">';
        echo '<section class="module module-small-bottom shop_isle_hidden_if_not_customizer">';
    }
    if (isset($shop_isle_products_slider_single_hide) && $shop_isle_products_slider_single_hide != 1 || isset($wp_customize)) {
        echo '<div class="container">';
        $shop_isle_products_slider_title = get_theme_mod('shop_isle_products_slider_title', __('Exclusive products', 'shop-isle'));
        $shop_isle_products_slider_subtitle = get_theme_mod('shop_isle_products_slider_subtitle', __('Special category of products', 'shop-isle'));
        if (!empty($shop_isle_products_slider_title) || !empty($shop_isle_products_slider_subtitle)) {
            echo '<div class="row">';
            echo '<div class="col-sm-6 col-sm-offset-3">';
            if (!empty($shop_isle_products_slider_title)) {
                echo '<h2 class="module-title font-alt">' . $shop_isle_products_slider_title . '</h2>';
            }
            if (!empty($shop_isle_products_slider_subtitle)) {
                echo '<div class="module-subtitle font-serif">' . $shop_isle_products_slider_subtitle . '</div>';
            }
            echo '</div>';
            echo '</div><!-- .row -->';
        }
        $shop_isle_products_slider_category = get_theme_mod('shop_isle_products_slider_category');
        if (!empty($shop_isle_products_slider_category) && $shop_isle_products_slider_category != '-') {
            $shop_isle_products_slider_args = array('post_type' => 'product', 'posts_per_page' => 10, 'tax_query' => array(array('taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $shop_isle_products_slider_category)));
            $shop_isle_products_slider_loop = new WP_Query($shop_isle_products_slider_args);
            if ($shop_isle_products_slider_loop->have_posts()) {
                echo '<div class="row">';
                echo '<div class="owl-carousel text-center" data-items="5" data-pagination="false" data-navigation="false">';
                while ($shop_isle_products_slider_loop->have_posts()) {
                    $shop_isle_products_slider_loop->the_post();
                    echo '<div class="owl-item">';
                    echo '<div class="col-sm-12">';
                    echo '<div class="ex-product">';
                    echo '<a href="' . get_permalink() . '">' . woocommerce_get_product_thumbnail() . '</a>';
                    echo '<h4 class="shop-item-title font-alt"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h4>';
                    $product = new WC_Product(get_the_ID());
                    $rating_html = $product->get_rating_html($product->get_average_rating());
                    if ($rating_html && get_option('woocommerce_enable_review_rating') === 'yes') {
                        echo '<div class="product-rating-home">' . $rating_html . '</div>';
                    }
                    if (!empty($product)) {
                        if (function_exists('get_woocommerce_price_format')) {
                            $format_string = get_woocommerce_price_format();
                        }
                        if (!empty($format_string)) {
                            switch ($format_string) {
                                case '%1$s%2$s':
                                    echo get_woocommerce_currency_symbol() . $product->price;
                                    break;
                                case '%2$s%1$s':
                                    echo $product->price . get_woocommerce_currency_symbol();
                                    break;
                                case '%1$s&nbsp;%2$s':
                                    echo get_woocommerce_currency_symbol() . ' ' . $product->price;
                                    break;
                                case '%2$s&nbsp;%1$s':
                                    echo $product->price . ' ' . get_woocommerce_currency_symbol();
                                    break;
                            }
                        } else {
                            echo get_woocommerce_currency_symbol() . $product->price;
                        }
                    }
                    echo '</div>';
                    echo '</div>';
                    echo '</div>';
                }
                wp_reset_postdata();
                echo '</div>';
                echo '</div>';
            }
        } else {
            $shop_isle_products_slider_args = array('post_type' => 'product', 'posts_per_page' => 10);
            $shop_isle_products_slider_loop = new WP_Query($shop_isle_products_slider_args);
            if ($shop_isle_products_slider_loop->have_posts()) {
                echo '<div class="row">';
                echo '<div class="owl-carousel text-center" data-items="5" data-pagination="false" data-navigation="false">';
                while ($shop_isle_products_slider_loop->have_posts()) {
                    $shop_isle_products_slider_loop->the_post();
                    echo '<div class="owl-item">';
                    echo '<div class="col-sm-12">';
                    echo '<div class="ex-product">';
                    echo '<a href="' . get_permalink() . '">' . woocommerce_get_product_thumbnail() . '</a>';
                    echo '<h4 class="shop-item-title font-alt"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h4>';
                    $product = new WC_Product(get_the_ID());
                    $rating_html = $product->get_rating_html($product->get_average_rating());
                    if ($rating_html && get_option('woocommerce_enable_review_rating') === 'yes') {
                        echo '<div class="product-rating-home">' . $rating_html . '</div>';
                    }
                    if (!empty($product)) {
                        if (function_exists('get_woocommerce_price_format')) {
                            $format_string = get_woocommerce_price_format();
                        }
                        if (!empty($format_string)) {
                            switch ($format_string) {
                                case '%1$s%2$s':
                                    echo get_woocommerce_currency_symbol() . $product->price;
                                    break;
                                case '%2$s%1$s':
                                    echo $product->price . get_woocommerce_currency_symbol();
                                    break;
                                case '%1$s&nbsp;%2$s':
                                    echo get_woocommerce_currency_symbol() . ' ' . $product->price;
                                    break;
                                case '%2$s&nbsp;%1$s':
                                    echo $product->price . ' ' . get_woocommerce_currency_symbol();
                                    break;
                            }
                        } else {
                            echo get_woocommerce_currency_symbol() . $product->price;
                        }
                    }
                    echo '</div>';
                    echo '</div>';
                    echo '</div>';
                }
                wp_reset_postdata();
                echo '</div>';
                echo '</div>';
            }
        }
        echo '</div>';
        echo '</section>';
    }
}
        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 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;
 }