is_in_stock() public method

Returns whether or not the product is in stock.
public is_in_stock ( ) : boolean
return boolean
 /**
  * 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());
 }
示例#2
1
function woocs_product($ID, $attr, $currency = true)
{
    if (class_exists('WC_Product')) {
        $product = new WC_Product($ID);
        if ($attr == 'price_tax_inc') {
            $p = round($product->get_price_including_tax(), 2);
        } elseif ($attr == 'get_price_excluding_tax') {
            $p = round($product->get_price_excluding_tax(), 2);
        } elseif ($attr == 'get_price') {
            $p = round($product->get_price(), 2);
        } elseif ($attr == 'get_sale_price') {
            $p = round($product->get_sale_price(), 2);
        } elseif ($attr == 'get_regular_price') {
            $p = round($product->get_regular_price(), 2);
        } elseif ($attr == 'get_price_html') {
            $p = strip_tags($product->get_price_html());
        } elseif ($attr == 'is_in_stock') {
            $p = $product->is_in_stock();
        }
    }
    return $p;
}
 /**
  * Bundled product availability that takes quantity into account.
  *
  * @param  WC_Product   $product    the product
  * @param  int          $quantity   the quantity
  * @return array                    availability data
  */
 function get_bundled_product_availability($product, $quantity)
 {
     $availability = $class = '';
     if ($product->managing_stock()) {
         if ($product->is_in_stock() && $product->get_total_stock() > get_option('woocommerce_notify_no_stock_amount') && $product->get_total_stock() >= $quantity) {
             switch (get_option('woocommerce_stock_format')) {
                 case 'no_amount':
                     $availability = __('In stock', 'woocommerce');
                     break;
                 case 'low_amount':
                     if ($product->get_total_stock() <= get_option('woocommerce_notify_low_stock_amount')) {
                         $availability = sprintf(__('Only %s left in stock', 'woocommerce'), $product->get_total_stock());
                         if ($product->backorders_allowed() && $product->backorders_require_notification()) {
                             $availability .= ' ' . __('(can be backordered)', 'woocommerce');
                         }
                     } else {
                         $availability = __('In stock', 'woocommerce');
                     }
                     break;
                 default:
                     $availability = sprintf(__('%s in stock', 'woocommerce'), $product->get_total_stock());
                     if ($product->backorders_allowed() && $product->backorders_require_notification()) {
                         $availability .= ' ' . __('(can be backordered)', 'woocommerce');
                     }
                     break;
             }
             $class = 'in-stock';
         } elseif ($product->backorders_allowed() && $product->backorders_require_notification()) {
             if ($product->get_total_stock() >= $quantity || get_option('woocommerce_stock_format') == 'no_amount') {
                 $availability = __('Available on backorder', 'woocommerce');
             } else {
                 $availability = __('Available on backorder', 'woocommerce') . ' ' . sprintf(__('(only %s left in stock)', 'woocommerce-product-bundles'), $product->get_total_stock());
             }
             $class = 'available-on-backorder';
         } elseif ($product->backorders_allowed()) {
             $availability = __('In stock', 'woocommerce');
             $class = 'in-stock';
         } else {
             if ($product->is_in_stock() && $product->get_total_stock() > get_option('woocommerce_notify_no_stock_amount')) {
                 if (get_option('woocommerce_stock_format') == 'no_amount') {
                     $availability = __('Insufficient stock', 'woocommerce-product-bundles');
                 } else {
                     $availability = __('Insufficient stock', 'woocommerce-product-bundles') . ' ' . sprintf(__('(only %s left in stock)', 'woocommerce-product-bundles'), $product->get_total_stock());
                 }
                 $class = 'out-of-stock';
             } else {
                 $availability = __('Out of stock', 'woocommerce');
                 $class = 'out-of-stock';
             }
         }
     } elseif (!$product->is_in_stock()) {
         $availability = __('Out of stock', 'woocommerce');
         $class = 'out-of-stock';
     }
     _deprecated_function('get_bundled_product_availability', '4.8.8', 'WC_Bundled_Item::get_availability()');
     return apply_filters('woocommerce_get_bundled_product_availability', array('availability' => $availability, 'class' => $class), $product);
 }
 function TS_VCSC_WooCommerce_ImageGrid_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');
     wp_enqueue_style('ts-font-ecommerce');
     wp_enqueue_style('ts-extend-simptip');
     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', 'limit_posts' => 'true', 'limit_by' => 'category', 'limit_term' => '', 'filter_by' => 'category', 'posts_limit' => 25, 'content_images_size' => 'medium', 'filters_show' => 'true', 'filters_available' => 'Available Groups', 'filters_selected' => 'Filtered Groups', 'filters_nogroups' => 'No Groups', 'filters_toggle' => 'Toggle Filter', 'filters_toggle_style' => '', 'filters_showall' => 'Show All', 'filters_showall_style' => '', 'data_grid_machine' => 'internal', 'data_grid_invalid' => 'false', 'data_grid_target' => '_blank', 'data_grid_breaks' => '240,480,720,960', 'data_grid_width' => 250, 'data_grid_space' => 2, 'data_grid_order' => 'false', 'data_grid_always' => 'true', 'data_grid_price' => 'true', 'fullwidth' => 'false', 'breakouts' => 6, 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts));
     // Check for Front End Editor
     if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") {
         $grid_class = 'ts-image-link-grid-edit';
         $grid_message = '<div class="ts-composer-frontedit-message">' . __('The grid is currently viewed in front-end edit mode; grid and filter features are disabled for performance and compatibility reasons.', "ts_visual_composer_extend") . '</div>';
         $image_style = 'width: 20%; height: 100%; display: inline-block; margin: 0; padding: 0;';
         $grid_style = 'height: 100%;';
         $frontend_edit = 'true';
     } else {
         if ($data_grid_machine == 'internal') {
             $grid_class = 'ts-image-link-grid';
         } else {
             if ($data_grid_machine == 'freewall') {
                 $grid_class = 'ts-freewall-link-grid';
             }
         }
         $image_style = '';
         $grid_style = '';
         $grid_message = '';
         $frontend_edit = 'false';
     }
     $randomizer = mt_rand(999999, 9999999);
     if (!empty($el_id)) {
         $modal_id = $el_id;
     } else {
         $modal_id = 'ts-vcsc-product-link-grid-' . $randomizer;
     }
     $valid_images = 0;
     if (!empty($data_grid_breaks)) {
         $data_grid_breaks = str_replace(' ', '', $data_grid_breaks);
         $count_columns = substr_count($data_grid_breaks, ",") + 1;
     } else {
         $count_columns = 0;
     }
     $i = -1;
     $b = 0;
     $output = '';
     if ($filters_toggle_style != '') {
         wp_enqueue_style('ts-extend-buttonsflat');
     }
     wp_enqueue_style('ts-extend-multiselect');
     wp_enqueue_script('ts-extend-multiselect');
     $meta_query = '';
     $menu_tax = 'product_cat';
     $limit_tax = 'product_cat';
     // 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 ($data_grid_machine == 'internal') {
         $class_name = 'ts-image-link-grid-frame';
     } else {
         if ($data_grid_machine == 'freewall') {
             wp_enqueue_script('ts-extend-freewall');
             $class_name = 'ts-image-freewall-grid-frame';
         }
     }
     if (function_exists('vc_shortcode_custom_css_class')) {
         $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $el_class . ' ' . $class_name . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_ImageGrid_Basic', $atts);
     } else {
         $css_class = $class_name . ' ' . $el_class;
     }
     $fullwidth_allow = "true";
     $postCounter = 0;
     $modal_gallery = '';
     // Front-Edit Message
     if ($frontend_edit == "true") {
         $modal_gallery .= $grid_message;
         if ($loop->have_posts()) {
             while ($loop->have_posts()) {
                 $loop->the_post();
                 $matched_terms = 0;
                 $post_thumbnail = get_the_post_thumbnail();
                 if ($matched_terms == 0 && ($post_thumbnail != '' || $data_grid_invalid == "false")) {
                     $postCounter++;
                     if ($postCounter < $posts_limit + 1) {
                         $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();
                         $product_sku = $product->get_sku();
                         $attributes = $product->get_attributes();
                         $stock = $product->is_in_stock() ? 'true' : 'false';
                         if ('' != $post_thumbnail) {
                             $grid_image = wp_get_attachment_image_src(get_post_thumbnail_id(), $content_images_size);
                             $modal_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
                             $grid_image = $grid_image[0];
                             $modal_image = $modal_image[0];
                         } else {
                             $grid_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png');
                             $modal_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png');
                         }
                         $categories = array();
                         if (taxonomy_exists($menu_tax)) {
                             foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) {
                                 array_push($categories, $term->name);
                             }
                             $categories = implode($categories, ',');
                         }
                         $valid_images++;
                         $modal_gallery .= '<a style="' . $image_style . '" href="' . get_permalink() . '" target="_blank" title="' . get_the_title() . '">';
                         $modal_gallery .= '<img id="ts-image-link-picture-' . $randomizer . '-' . $i . '" class="ts-image-link-picture" src="' . $grid_image . '" rel="link-group-' . $randomizer . '" data-include="true" data-image="' . $modal_image . '" width="100%" height="auto" title="' . get_the_title() . '" data-groups="' . $categories . '" data-target="' . $data_grid_target . '" data-link="' . get_permalink() . '">';
                         $modal_gallery .= '</a>';
                         $categories = array();
                     }
                 }
             }
         } else {
             echo __("No products could be found.", "ts_visual_composer_extend");
         }
         wp_reset_postdata();
         wp_reset_query();
     } else {
         if ($loop->have_posts()) {
             if ($data_grid_machine == 'freewall') {
                 $filter_settings = 'data-gridfilter="' . $filters_show . '" data-gridavailable="' . $filters_available . '" data-gridselected="' . $filters_selected . '" data-gridnogroups="' . $filters_nogroups . '" data-gridtoggle="' . $filters_toggle . '" data-gridtogglestyle="' . $filters_toggle_style . '" data-gridshowall="' . $filters_showall . '" data-gridshowallstyle="' . $filters_showall_style . '"';
                 $modal_gallery .= '<div id="ts-lightbox-freewall-grid-' . $randomizer . '-container" class="ts-lightbox-freewall-grid-container" data-random="' . $randomizer . '" data-width="' . $data_grid_width . '" data-gutter="' . $data_grid_space . '" ' . $filter_settings . ' style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px;">';
             }
             while ($loop->have_posts()) {
                 $loop->the_post();
                 $matched_terms = 0;
                 $post_thumbnail = get_the_post_thumbnail();
                 if ($matched_terms == 0 && ($post_thumbnail != '' || $data_grid_invalid == "false")) {
                     $postCounter++;
                     if ($postCounter < $posts_limit + 1) {
                         $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();
                         $product_sku = $product->get_sku();
                         $attributes = $product->get_attributes();
                         $stock = $product->is_in_stock() ? 'true' : 'false';
                         if ('' != $post_thumbnail) {
                             $grid_image = wp_get_attachment_image_src(get_post_thumbnail_id(), $content_images_size);
                             $modal_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
                             $grid_image = $grid_image[0];
                             $modal_image = $modal_image[0];
                         } else {
                             $grid_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png');
                             $modal_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png');
                         }
                         $categories = array();
                         if (taxonomy_exists($menu_tax)) {
                             if ($filters_show == "true") {
                                 foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) {
                                     array_push($categories, $term->name);
                                 }
                             }
                             $categories = implode($categories, ',');
                         }
                         $valid_images++;
                         $costs = $product->price;
                         $costs = is_numeric($costs) ? wc_price($costs) : $costs;
                         $costs = strip_tags($costs);
                         if ($data_grid_price == "true") {
                             $price = $costs . ' / ';
                         } else {
                             $price = '';
                         }
                         if ($data_grid_machine == 'internal') {
                             $modal_gallery .= '<img id="ts-image-link-picture-' . $randomizer . '-' . $i . '" class="ts-image-link-picture" src="' . $grid_image . '" rel="link-group-' . $randomizer . '" data-no-lazy="1" data-price="' . $costs . '" data-include="true" data-image="' . $modal_image . '" width="100%" height="auto" title="' . $price . get_the_title() . '" data-groups="' . $categories . '" data-target="' . $data_grid_target . '" data-link="' . get_permalink() . '">';
                         } else {
                             if ($data_grid_machine == 'freewall') {
                                 $modal_gallery .= '<div id="ts-lightbox-freewall-item-' . $randomizer . '-' . $i . '-parent" class="ts-lightbox-freewall-item ts-lightbox-freewall-active ' . $el_class . ' nchgrid-item nchgrid-tile" data-fixSize="false" data-groups="' . $categories . '" data-target="' . $data_grid_target . '" data-link="' . get_permalink() . '" data-showing="true" data-groups="' . (!empty($categories) ? str_replace('/', ',', $categories) : "") . '" style="width: ' . $data_grid_width . 'px; margin: 0; padding: 0;">';
                                 $modal_gallery .= '<a id="ts-lightbox-freewall-item-' . $randomizer . '-' . $i . '" href="' . get_permalink() . '" target="' . $data_grid_target . '" title="' . get_the_title() . '">';
                                 $modal_gallery .= '<img id="ts-lightbox-freewall-picture-' . $randomizer . '-' . $i . '" class="ts-lightbox-freewall-picture" src="' . $grid_image . '" width="100%" height="auto" title="' . $price . get_the_title() . '">';
                                 $modal_gallery .= '<div class="nchgrid-caption"></div>';
                                 $modal_gallery .= '<div class="nchgrid-caption-text ' . ($data_grid_always == 'true' ? 'nchgrid-caption-text-always' : '') . '">' . $price . get_the_title() . '</div>';
                                 $modal_gallery .= '</a>';
                                 $modal_gallery .= '</div>';
                             }
                         }
                         $categories = array();
                     }
                 }
             }
             if ($data_grid_machine == 'freewall') {
                 $modal_gallery .= '</div>';
             }
         } else {
             echo __("No products could be found.", "ts_visual_composer_extend");
         }
         wp_reset_postdata();
         wp_reset_query();
     }
     if ($valid_images < $count_columns) {
         $data_grid_string = explode(',', $data_grid_breaks);
         $data_grid_breaks = array();
         foreach ($data_grid_string as $single_break) {
             $b++;
             if ($b <= $valid_images) {
                 array_push($data_grid_breaks, $single_break);
             } else {
                 break;
             }
         }
         $data_grid_breaks = implode(",", $data_grid_breaks);
     } else {
         $data_grid_breaks = $data_grid_breaks;
     }
     $output .= '<div id="' . $modal_id . '-frame" class="' . $grid_class . ' ' . $css_class . ' ' . ($fullwidth == "true" && $fullwidth_allow == "true" ? "ts-lightbox-nacho-full-frame" : "") . '" data-random="' . $randomizer . '" data-grid="' . $data_grid_breaks . '" data-margin="' . $data_grid_space . '" data-always="' . $data_grid_always . '" data-order="' . $data_grid_order . '" data-break-parents="' . $breakouts . '" data-inline="' . $frontend_edit . '" data-gridfilter="' . $filters_show . '" data-gridavailable="' . $filters_available . '" data-gridselected="' . $filters_selected . '" data-gridnogroups="' . $filters_nogroups . '" data-gridtoggle="' . $filters_toggle . '" data-gridtogglestyle="' . $filters_toggle_style . '" data-gridshowall="' . $filters_showall . '" data-gridshowallstyle="' . $filters_showall_style . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px; position: relative;">';
     if ($data_grid_machine == 'internal') {
         $output .= '<div id="nch-lb-grid-' . $randomizer . '" class="nch-lb-grid" data-filter="nch-lb-filter-' . $randomizer . '" style="' . $grid_style . '" data-toggle="nch-lb-toggle-' . $randomizer . '" data-random="' . $randomizer . '">';
     }
     $output .= $modal_gallery;
     if ($data_grid_machine == 'internal') {
         $output .= '</div>';
     }
     $output .= '</div>';
     echo $output;
     $myvariable = ob_get_clean();
     return $myvariable;
 }
示例#5
0
/**
 * Build a Google Shopping Content Product from a WC Product
 * @param WC_Product $wc_product
 * @return Google_Service_ShoppingContent_Product
 */
function woogle_build_product($wc_product)
{
    // Create Google Shopping Content Product
    require_once plugin_dir_path(woogle_get_plugin_file()) . 'vendor/google-api-php-client/src/Google/Service/ShoppingContent.php';
    $product = new Google_Service_ShoppingContent_Product();
    // Custom Attributes
    $product_custom_attributes = array();
    // Product identifiers
    $sku = $wc_product->get_sku();
    if (empty($sku)) {
        if ($wc_product->is_type('variation')) {
            $product->setOfferId($wc_product->variation_id);
        } else {
            $product->setOfferId($wc_product->id);
        }
    } else {
        $product->setOfferId($sku);
    }
    if ($wc_product->is_type('variation')) {
        $product->setItemGroupId($wc_product->parent->id);
    }
    $woocommerce_id_attribute = new Google_Service_ShoppingContent_ProductCustomAttribute();
    $woocommerce_id_attribute->setName('woocommerce_id');
    $woocommerce_id_attribute->setValue($wc_product->id);
    $woocommerce_id_attribute->setType('int');
    $product_custom_attributes[] = $woocommerce_id_attribute;
    // Title
    $woogle_title = get_post_meta($wc_product->id, '_woogle_title', true);
    if (!empty($woogle_title)) {
        $product->setTitle(html_entity_decode(strip_tags($woogle_title)));
    } else {
        $product->setTitle(html_entity_decode(strip_tags($wc_product->get_title())));
    }
    // Description
    $woogle_description = get_post_meta($wc_product->id, '_woogle_description', true);
    if (!empty($woogle_description)) {
        $product->setDescription(html_entity_decode(strip_tags($woogle_description)));
    } else {
        $product->setDescription(html_entity_decode(strip_tags($wc_product->post->post_content)));
    }
    $product->setLink($wc_product->get_permalink());
    $image = $wc_product->get_image();
    $post_thumbnail_id = get_post_thumbnail_id($wc_product->id);
    if ($post_thumbnail_id) {
        $image_src = wp_get_attachment_image_src($post_thumbnail_id);
        $product->setImageLink(@$image_src[0]);
    }
    $product->setContentLanguage(substr(get_locale(), 0, 2));
    $product->setTargetCountry(WC()->countries->get_base_country());
    $product->setChannel('online');
    $product->setAvailability($wc_product->is_in_stock() ? 'in stock' : 'out of stock');
    // Condition
    $condition = get_post_meta($wc_product->id, '_woogle_condition', true);
    if (!empty($condition)) {
        $product->setCondition($condition);
    } else {
        $product->setcondition('new');
    }
    // Category
    $category = get_post_meta($wc_product->id, '_woogle_category', true);
    if (!empty($category)) {
        $product->setGoogleProductCategory($category);
    }
    // Brand
    $brand = get_post_meta($wc_product->id, '_woogle_brand', true);
    if (!empty($brand)) {
        $product->setBrand($brand);
    }
    // GTIN
    $gtin = get_post_meta($wc_product->id, '_woogle_gtin', true);
    if (!empty($gtin)) {
        $product->setGtin($gtin);
    }
    // MPN
    $mpn = get_post_meta($wc_product->id, '_woogle_mpn', true);
    if (!empty($mpn)) {
        $product->setMpn($mpn);
    }
    if (empty($gtin) && empty($mpn)) {
        $product->setIdentifierExists(false);
    }
    // Price
    $price = new Google_Service_ShoppingContent_Price();
    $price->setValue($wc_product->get_regular_price());
    $price->setCurrency(get_woocommerce_currency());
    $product->setPrice($price);
    // Sale price
    $wc_sale_price = $wc_product->get_sale_price();
    if (!empty($wc_sale_price)) {
        $sale_price = new Google_Service_ShoppingContent_Price();
        $sale_price->setValue($wc_sale_price);
        $sale_price->setCurrency(get_woocommerce_currency());
        $product->setSalePrice($sale_price);
        $post_id = $wc_product->is_type('variation') ? $wc_product->variation_id : $wc_product->id;
        $sale_price_dates_from = get_post_meta($post_id, '_sale_price_dates_from', true);
        $sale_price_dates_to = get_post_meta($post_id, '_sale_price_dates_to', true);
        if (!empty($sale_price_dates_from) && !empty($sale_price_dates_to)) {
            $effective_date_start = date('c', intval($sale_price_dates_from));
            $effective_date_end = date('c', intval($sale_price_dates_to));
            $product->setSalePriceEffectiveDate("{$effective_date_start}/{$effective_date_end}");
        }
    }
    // Shipping fields
    // Shipping weight
    $wc_product_weight = $wc_product->get_weight();
    if (!empty($wc_product_weight)) {
        $shipping_weight = new Google_Service_ShoppingContent_ProductShippingWeight();
        $shipping_weight->setValue($wc_product_weight);
        $shipping_weight->setUnit(get_option('woocommerce_weight_unit', 'kg'));
        $product->setShippingWeight($shipping_weight);
    }
    // Shipping dimensions
    $wc_dimension_unit = get_option('woocommerce_dimension_unit', 'cm');
    $wc_product_length = $wc_product->get_length();
    if (!empty($wc_product_length)) {
        $dimension = new Google_Service_ShoppingContent_ProductShippingDimension();
        $dimension->setValue($wc_product_length);
        $dimension->setUnit($wc_dimension_unit);
        $product->setShippingLength($dimension);
    }
    $wc_product_width = $wc_product->get_width();
    if (!empty($wc_product_width)) {
        $dimension = new Google_Service_ShoppingContent_ProductShippingDimension();
        $dimension->setValue($wc_product_width);
        $dimension->setUnit($wc_dimension_unit);
        $product->setShippingWidth($dimension);
    }
    $wc_product_height = $wc_product->get_height();
    if (!empty($wc_product_height)) {
        $dimension = new Google_Service_ShoppingContent_ProductShippingDimension();
        $dimension->setValue($wc_product_height);
        $dimension->setUnit($wc_dimension_unit);
        $product->setShippingHeight($dimension);
    }
    // Attributes
    $color = null;
    $material = null;
    $pattern = null;
    $size = null;
    $age_group = null;
    $gender = null;
    $adult = null;
    if ($wc_product->is_type('variation')) {
        // Variable product
        $wc_variation_attributes = $wc_product->get_variation_attributes();
        foreach ($wc_variation_attributes as $name => $value) {
            if (!empty($value)) {
                $attribute = new Google_Service_ShoppingContent_ProductCustomAttribute();
                $attribute->setName($name);
                $attribute->setValue($value);
                $attribute->setType('text');
                $product_custom_attributes[] = $attribute;
                // Google attributes
                if (empty($color)) {
                    $color = woogle_maybe_get_attribute('color', $name, $value);
                }
                if (empty($material)) {
                    $material = woogle_maybe_get_attribute('material', $name, $value);
                }
                if (empty($pattern)) {
                    $pattern = woogle_maybe_get_attribute('pattern', $name, $value);
                }
                if (empty($size)) {
                    $size = woogle_maybe_get_attribute('size', $name, $value);
                }
                if (empty($age_group)) {
                    $age_group = woogle_maybe_get_attribute('age-group', $name, $value);
                }
                if (empty($gender)) {
                    $gender = woogle_maybe_get_attribute('gender', $name, $value);
                }
                if (empty($adult)) {
                    $adult = woogle_maybe_get_attribute('adult', $name, $value);
                }
            }
        }
    } else {
        // Simple product
        $wc_attributes = $wc_product->get_attributes();
        foreach ($wc_attributes as $name => $wc_attribute) {
            if ($wc_attribute['is_taxonomy']) {
                $term_values = array();
                $terms = wp_get_post_terms($wc_product->id, $name);
                foreach ($terms as $term) {
                    $term_values[] = $term->slug;
                }
                if (!empty($term_values)) {
                    $value = implode(',', $term_values);
                    $attribute = new Google_Service_ShoppingContent_ProductCustomAttribute();
                    $attribute->setName($name);
                    $attribute->setValue($value);
                    $attribute->setType('text');
                    $product_custom_attributes[] = $attribute;
                    // Google attributes
                    if (empty($color)) {
                        $color = woogle_maybe_get_attribute('color', $name, $value);
                    }
                    if (empty($material)) {
                        $material = woogle_maybe_get_attribute('material', $name, $value);
                    }
                    if (empty($pattern)) {
                        $pattern = woogle_maybe_get_attribute('pattern', $name, $value);
                    }
                    if (empty($size)) {
                        $size = woogle_maybe_get_attribute('size', $name, $value);
                    }
                    if (empty($age_group)) {
                        $age_group = woogle_maybe_get_attribute('age-group', $name, $value);
                    }
                    if (empty($gender)) {
                        $gender = woogle_maybe_get_attribute('gender', $name, $value);
                    }
                    if (empty($adult)) {
                        $adult = woogle_maybe_get_attribute('adult', $name, $value);
                    }
                }
            }
        }
    }
    /*
     * Physical properties
     */
    // Color
    if (empty($color)) {
        $color = get_post_meta($wc_product->id, '_woogle_color', true);
    }
    if (!empty($color)) {
        $product->setColor($color);
    }
    // Material
    if (empty($material)) {
        $material = get_post_meta($wc_product->id, '_woogle_material', true);
    }
    if (!empty($material)) {
        $product->setMaterial($material);
    }
    // Pattern
    if (empty($pattern)) {
        $pattern = get_post_meta($wc_product->id, '_woogle_pattern', true);
    }
    if (!empty($pattern)) {
        $product->setPattern($pattern);
    }
    // Size
    if (empty($size)) {
        $size = get_post_meta($wc_product->id, '_woogle_size', true);
    }
    if (!empty($size)) {
        $product->setSizes(explode(', ', $size));
        $product->setSizeSystem(WC()->countries->get_base_country());
    }
    /*
     * Target consumer
     */
    // Age Group
    if (empty($age_group)) {
        $age_group = get_post_meta($wc_product->id, '_woogle_age_group', true);
    }
    if (!empty($age_group)) {
        $product->setAgeGroup($age_group);
    }
    // Gender
    if (empty($gender)) {
        $gender = get_post_meta($wc_product->id, '_woogle_gender', true);
    }
    if (!empty($gender)) {
        $product->setGender($gender);
    }
    // Gender
    if (empty($adult)) {
        $adult = get_post_meta($wc_product->id, '_woogle_adult', true);
    }
    if (!empty($adult) && $adult != 'no') {
        $product->setAdult(true);
    }
    $product->setCustomAttributes($product_custom_attributes);
    return $product;
}
 /**
  * Apply the shop loop add to cart button text customization
  *
  * @since 1.2.0
  * @param string $text add to cart text
  * @param WC_Product $product product object
  * @return string modified add to cart text
  */
 public function customize_add_to_cart_text($text, $product)
 {
     // out of stock add to cart text
     if (isset($this->filters['out_of_stock_add_to_cart_text']) && !$product->is_in_stock()) {
         return $this->filters['out_of_stock_add_to_cart_text'];
     }
     if (isset($this->filters['add_to_cart_text']) && $product->is_type('simple')) {
         // simple add to cart text
         return $this->filters['add_to_cart_text'];
     } elseif (isset($this->filters['variable_add_to_cart_text']) && $product->is_type('variable')) {
         // variable add to cart text
         return $this->filters['variable_add_to_cart_text'];
     } elseif (isset($this->filters['grouped_add_to_cart_text']) && $product->is_type('grouped')) {
         // grouped add to cart text
         return $this->filters['grouped_add_to_cart_text'];
     } elseif (isset($this->filters['external_add_to_cart_text']) && $product->is_type('external')) {
         // external add to cart text
         return $this->filters['external_add_to_cart_text'];
     }
     return $text;
 }
示例#7
0
 $end_date = null;
 if (!empty($ticket->end_date)) {
     $end_date = strtotime($ticket->end_date . $gmt_offset);
 } else {
     $end_date = strtotime(tribe_get_end_date(get_the_ID(), false, 'Y-m-d G:i') . $gmt_offset);
 }
 $start_date = null;
 if (!empty($ticket->start_date)) {
     $start_date = strtotime($ticket->start_date . $gmt_offset);
 }
 if ((empty($start_date) || time() > $start_date) && (empty($end_date) || time() < $end_date)) {
     $is_there_any_product = true;
     echo sprintf('<input type="hidden" name="product_id[]" value="%d">', $ticket->ID);
     echo '<tr>';
     echo '<td class="woocommerce">';
     if ($product->is_in_stock()) {
         // Max quantity will be left open if backorders allowed, restricted to 1 if the product is
         // constrained to be sold individually or else set to the available stock quantity
         $max_quantity = $product->backorders_allowed() ? '' : $product->get_stock_quantity();
         $max_quantity = $product->is_sold_individually() ? 1 : $max_quantity;
         woocommerce_quantity_input(array('input_name' => 'quantity_' . $ticket->ID, 'input_value' => 0, 'min_value' => 0, 'max_value' => $max_quantity));
         $is_there_any_product_to_sell = true;
     } else {
         echo '<span class="tickets_nostock">' . esc_html__('Out of stock!', 'tribe-wootickets') . '</span>';
     }
     echo '</td>';
     echo '<td nowrap="nowrap" class="tickets_name">';
     echo $ticket->name;
     echo '</td>';
     echo '<td class="tickets_price">';
     echo $this->get_price_html($product);
 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;
 }
示例#9
0
 /**
  * Add a product to the cart
  *
  * @param string $product_id contains the id of the product to add to the cart
  * @param string $quantity contains the quantity of the item to add
  * @param int $variation_id
  * @param array $variation attribute values
  * @param array $cart_item_data extra cart item data we want to pass into the item
  * @return bool
  */
 function add_to_cart($product_id, $quantity = 1, $variation_id = '', $variation = '', $cart_item_data = array())
 {
     global $woocommerce;
     if ($quantity < 1) {
         return false;
     }
     // Load cart item data - may be added by other plugins
     $cart_item_data = (array) apply_filters('woocommerce_add_cart_item_data', $cart_item_data, $product_id);
     // Generate a ID based on product ID, variation ID, variation data, and other cart item data
     $cart_id = $this->generate_cart_id($product_id, $variation_id, $variation, $cart_item_data);
     // See if this product and its options is already in the cart
     $cart_item_key = $this->find_product_in_cart($cart_id);
     if ($variation_id > 0) {
         $product_data = new WC_Product_Variation($variation_id);
     } else {
         $product_data = new WC_Product($product_id);
     }
     // Force quantity to 1 if sold individually
     if ($product_data->is_sold_individually()) {
         $quantity = 1;
     }
     // Type/Exists check
     if ($product_data->is_type('external') || !$product_data->exists()) {
         $woocommerce->add_error(__('This product cannot be purchased.', 'woocommerce'));
         return false;
     }
     // Price set check
     if ($product_data->get_price() === '') {
         $woocommerce->add_error(__('This product cannot be purchased - the price is not yet set.', 'woocommerce'));
         return false;
     }
     // Stock check - only check if we're managing stock and backorders are not allowed
     if (!$product_data->has_enough_stock($quantity)) {
         $woocommerce->add_error(sprintf(__('You cannot add that amount to the cart since there is not enough stock. We have %s in stock.', 'woocommerce'), $product_data->get_stock_quantity()));
         return false;
     } elseif (!$product_data->is_in_stock()) {
         $woocommerce->add_error(__('You cannot add that product to the cart since the product is out of stock.', 'woocommerce'));
         return false;
     }
     // Downloadable/virtual qty check
     if ($product_data->is_sold_individually()) {
         $in_cart_quantity = $cart_item_key ? $this->cart_contents[$cart_item_key]['quantity'] + $quantity : $quantity;
         // If its greater than 1, its already in the cart
         if ($in_cart_quantity > 1) {
             $woocommerce->add_error(sprintf('<a href="%s" class="button">%s</a> %s', get_permalink(woocommerce_get_page_id('cart')), __('View Cart &rarr;', 'woocommerce'), __('You already have this item in your cart.', 'woocommerce')));
             return false;
         }
     }
     // Stock check - this time accounting for whats already in-cart
     $product_qty_in_cart = $this->get_cart_item_quantities();
     if ($product_data->managing_stock()) {
         // Variations
         if ($variation_id && $product_data->variation_has_stock) {
             if (isset($product_qty_in_cart[$variation_id]) && !$product_data->has_enough_stock($product_qty_in_cart[$variation_id] + $quantity)) {
                 $woocommerce->add_error(sprintf(__('<a href="%s" class="button">%s</a> You cannot add that amount to the cart &mdash; we have %s in stock and you already have %s in your cart.', 'woocommerce'), get_permalink(woocommerce_get_page_id('cart')), __('View Cart &rarr;', 'woocommerce'), $product_data->get_stock_quantity(), $product_qty_in_cart[$variation_id]));
                 return false;
             }
             // Products
         } else {
             if (isset($product_qty_in_cart[$product_id]) && !$product_data->has_enough_stock($product_qty_in_cart[$product_id] + $quantity)) {
                 $woocommerce->add_error(sprintf(__('<a href="%s" class="button">%s</a> You cannot add that amount to the cart &mdash; we have %s in stock and you already have %s in your cart.', 'woocommerce'), get_permalink(woocommerce_get_page_id('cart')), __('View Cart &rarr;', 'woocommerce'), $product_data->get_stock_quantity(), $product_qty_in_cart[$product_id]));
                 return false;
             }
         }
     }
     // If cart_item_key is set, the item is already in the cart
     if ($cart_item_key) {
         $new_quantity = $quantity + $this->cart_contents[$cart_item_key]['quantity'];
         $this->set_quantity($cart_item_key, $new_quantity);
     } else {
         $cart_item_key = $cart_id;
         // Add item after merging with $cart_item_data - hook to allow plugins to modify cart item
         $this->cart_contents[$cart_item_key] = apply_filters('woocommerce_add_cart_item', array_merge($cart_item_data, array('product_id' => $product_id, 'variation_id' => $variation_id, 'variation' => $variation, 'quantity' => $quantity, 'data' => $product_data)), $cart_item_key);
     }
     do_action('woocommerce_add_to_cart', $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data);
     $woocommerce->cart_has_contents_cookie(true);
     $this->set_session();
     return true;
 }
 function TS_VCSC_WooCommerce_Slider_Basic_Function($atts, $content = null)
 {
     global $VISUAL_COMPOSER_EXTENSIONS;
     global $product;
     global $woocommerce;
     ob_start();
     wp_enqueue_script('ts-extend-hammer');
     wp_enqueue_script('ts-extend-nacho');
     wp_enqueue_style('ts-extend-nacho');
     if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndWaypoints == "true") {
         if (wp_script_is('waypoints', $list = 'registered')) {
             wp_enqueue_script('waypoints');
         } else {
             wp_enqueue_script('ts-extend-waypoints');
         }
     }
     wp_enqueue_style('ts-extend-owlcarousel2');
     wp_enqueue_script('ts-extend-owlcarousel2');
     wp_enqueue_style('ts-font-ecommerce');
     wp_enqueue_style('ts-extend-animations');
     wp_enqueue_style('ts-visual-composer-extend-front');
     wp_enqueue_script('ts-visual-composer-extend-front');
     extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'show_image' => 'true', 'link_page' => 'false', 'link_target' => '_parent', 'show_rating' => 'true', 'show_stock' => 'true', 'show_price' => 'true', 'show_link' => 'true', 'show_cart' => 'true', 'show_info' => 'true', 'show_content' => 'excerpt', 'cutoff_characters' => 400, 'products_slide' => 4, 'breakpoints_custom' => 'false', 'breakpoints_items' => '1,2,3,4,5,6,7,8', 'auto_height' => 'false', 'page_rtl' => 'false', 'auto_play' => 'false', 'show_bar' => 'false', 'bar_color' => '#dd3333', 'show_speed' => 5000, 'stop_hover' => 'true', 'show_navigation' => 'true', 'show_dots' => 'true', 'items_loop' => 'false', 'animation_in' => 'ts-viewport-css-flipInX', 'animation_out' => 'ts-viewport-css-slideOutDown', 'animation_mobile' => 'false', 'lightbox_group_name' => 'nachogroup', 'lightbox_size' => 'full', 'lightbox_effect' => 'random', 'lightbox_speed' => 5000, 'lightbox_social' => 'true', 'lightbox_backlight_choice' => 'predefined', 'lightbox_backlight_color' => '#0084E2', 'lightbox_backlight_custom' => '#000000', 'image_position' => 'ts-imagefloat-center', 'hover_type' => 'ts-imagehover-style1', 'hover_active' => 'false', 'overlay_trigger' => 'ts-trigger-hover', 'rating_maximum' => 5, 'rating_value' => 0, 'rating_quarter' => 'true', 'rating_dynamic' => '', 'rating_size' => 16, 'rating_auto' => 'false', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => 'ts-ecommerce-starfull1', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'false', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts));
     $woo_random = mt_rand(999999, 9999999);
     if (!empty($el_id)) {
         $woo_slider_id = $el_id;
     } else {
         $woo_slider_id = 'ts-vcsc-woocommerce-slider-' . $woo_random;
     }
     $output = '';
     // Backlight Color
     if ($lightbox_backlight_choice == "predefined") {
         $lightbox_backlight_selection = $lightbox_backlight_color;
     } else {
         $lightbox_backlight_selection = $lightbox_backlight_custom;
     }
     // Check for Front End Editor
     if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") {
         $slider_class = 'owl-carousel2-edit';
         $slider_message = '<div class="ts-composer-frontedit-message">' . __('The slider is currently viewed in front-end edit mode; slider features are disabled for performance and compatibility reasons.', "ts_visual_composer_extend") . '</div>';
         $product_style = 'width: ' . 100 / $products_slide . '%; height: 100%; float: left; margin: 0; padding: 0;';
         $frontend_edit = 'true';
         $description_style = 'display: none; padding: 15px;';
     } else {
         $slider_class = 'ts-owlslider-parent owl-carousel2';
         $slider_message = '';
         $product_style = '';
         $frontend_edit = 'false';
         $description_style = 'display: none; padding: 15px;';
     }
     $meta_query = '';
     // Recent Products
     if ($selection == "recent_products") {
         $meta_query = WC()->query->get_meta_query();
     }
     // Featured Products
     if ($selection == "featured_products") {
         $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes'));
     }
     // Top Rated Products
     if ($selection == "top_rated_products") {
         add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses'));
         $meta_query = WC()->query->get_meta_query();
     }
     // Final Query Arguments
     $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $frontend_edit == "true" ? $products_slide : $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query);
     // Products on Sale
     if ($selection == "sale_products") {
         $product_ids_on_sale = woocommerce_get_product_ids_on_sale();
         $meta_query = array();
         $meta_query[] = $woocommerce->query->visibility_meta_query();
         $meta_query[] = $woocommerce->query->stock_status_meta_query();
         $args['meta_query'] = $meta_query;
         $args['post__in'] = $product_ids_on_sale;
     }
     // Best Selling Products
     if ($selection == "best_selling_products") {
         $args['meta_key'] = 'total_sales';
         $args['orderby'] = 'meta_value_num';
         $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'));
     }
     // Products in Single Category
     if ($selection == "product_category") {
         $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN'));
     }
     // Products in Multiple Categories
     if ($selection == "product_categories") {
         $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN'));
     }
     // Start WordPress Query
     $loop = new WP_Query($args);
     if (function_exists('vc_shortcode_custom_css_class')) {
         $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $slider_class . ' ' . $el_class . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Slider_Basic', $atts);
     } else {
         $css_class = $slider_class . ' ' . $el_class;
     }
     $output .= '<div id="' . $woo_slider_id . '-container" class="ts-woocommerce-slider-container">';
     // Add Progressbar
     if ($auto_play == "true" && $show_bar == "true" && $frontend_edit == "false") {
         $output .= '<div id="ts-owlslider-progressbar-' . $woo_random . '" class="ts-owlslider-progressbar-holder" style=""><div class="ts-owlslider-progressbar" style="background: ' . $bar_color . '; height: 100%; width: 0%;"></div></div>';
     }
     // Add Navigation Controls
     if ($frontend_edit == "false") {
         $output .= '<div id="ts-owlslider-controls-' . $woo_random . '" class="ts-owlslider-controls" style="' . ($auto_play == "true" || $show_navigation == "true" ? "display: block;" : "display: none;") . '">';
         $output .= '<div id="ts-owlslider-controls-next-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>';
         $output .= '<div id="ts-owlslider-controls-prev-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>';
         if ($auto_play == "true") {
             $output .= '<div id="ts-owlslider-controls-play-' . $woo_random . '" class="ts-owlslider-controls-play active"><span class="ts-ecommerce-pause"></span></div>';
         }
         $output .= '</div>';
     }
     // Front-Edit Message
     if ($frontend_edit == "true") {
         $output .= $slider_message;
     }
     // Add Slider
     $output .= '<div id="' . $woo_slider_id . '" class="' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px;" data-id="' . $woo_random . '" data-items="' . $products_slide . '" data-breakpointscustom="' . $breakpoints_custom . '" data-breakpointitems="' . $breakpoints_items . '" data-rtl="' . $page_rtl . '" data-loop="' . $items_loop . '" data-navigation="' . $show_navigation . '" data-dots="' . $show_dots . '" data-mobile="' . $animation_mobile . '" data-animationin="' . $animation_in . '" data-animationout="' . $animation_out . '" data-height="' . $auto_height . '" data-play="' . $auto_play . '" data-bar="' . $show_bar . '" data-color="' . $bar_color . '" data-speed="' . $show_speed . '" data-hover="' . $stop_hover . '">';
     if ($loop->have_posts()) {
         while ($loop->have_posts()) {
             $loop->the_post();
             $product_id = get_the_ID();
             $product_title = get_the_title($product_id);
             $post = get_post($product_id);
             $product = new WC_Product($product_id);
             $attachment_ids = $product->get_gallery_attachment_ids();
             $price = $product->get_price_html();
             $product_sku = $product->get_sku();
             $attributes = $product->get_attributes();
             $stock = $product->is_in_stock() ? 'true' : 'false';
             $onsale = $product->is_on_sale() ? 'true' : 'false';
             // Rating Settings
             $rating_html = $product->get_rating_html();
             $rating = $product->get_average_rating();
             if ($rating == '') {
                 $rating = 0;
             }
             if ($rating_quarter == "true") {
                 $rating_value = floor($rating * 4) / 4;
             } else {
                 $rating_value = $rating;
             }
             $rating_value = number_format($rating_value, 2, $caption_digits, '');
             if ($rating_rtl == "false") {
                 $rating_width = $rating_value / $rating_maximum * 100;
             } else {
                 $rating_width = 100 - $rating_value / $rating_maximum * 100;
             }
             if ($rating_symbol == "other") {
                 if ($rating_icon == "ts-ecommerce-starfull1") {
                     $rating_class = 'ts-rating-stars-star1';
                 } else {
                     if ($rating_icon == "ts-ecommerce-starfull2") {
                         $rating_class = 'ts-rating-stars-star2';
                     } else {
                         if ($rating_icon == "ts-ecommerce-starfull3") {
                             $rating_class = 'ts-rating-stars-star3';
                         } else {
                             if ($rating_icon == "ts-ecommerce-starfull4") {
                                 $rating_class = 'ts-rating-stars-star4';
                             } else {
                                 if ($rating_icon == "ts-ecommerce-heartfull") {
                                     $rating_class = 'ts-rating-stars-heart1';
                                 } else {
                                     if ($rating_icon == "ts-ecommerce-heart") {
                                         $rating_class = 'ts-rating-stars-heart2';
                                     } else {
                                         if ($rating_icon == "ts-ecommerce-thumbsup") {
                                             $rating_class = 'ts-rating-stars-thumb';
                                         } else {
                                             if ($rating_icon == "ts-ecommerce-ribbon4") {
                                                 $rating_class = 'ts-rating-stars-ribbon';
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             } else {
                 $rating_class = 'ts-rating-stars-smile';
             }
             if ($rating_value >= 0 && $rating_value <= 1) {
                 $caption_class = 'ts-label-danger';
                 $caption_background = 'background-color: ' . $caption_danger . ';';
             } else {
                 if ($rating_value > 1 && $rating_value <= 2) {
                     $caption_class = 'ts-label-warning';
                     $caption_background = 'background-color: ' . $caption_warning . ';';
                 } else {
                     if ($rating_value > 2 && $rating_value <= 3) {
                         $caption_class = 'ts-label-info';
                         $caption_background = 'background-color: ' . $caption_info . ';';
                     } else {
                         if ($rating_value > 3 && $rating_value <= 4) {
                             $caption_class = 'ts-label-primary';
                             $caption_background = 'background-color: ' . $caption_primary . ';';
                         } else {
                             if ($rating_value > 4 && $rating_value <= 5) {
                                 $caption_class = 'ts-label-success';
                                 $caption_background = 'background-color: ' . $caption_success . ';';
                             }
                         }
                     }
                 }
             }
             if (has_post_thumbnail($loop->post->ID)) {
                 $featured = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
                 $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail');
                 $featured = $featured[0];
                 $thumbnail = $thumbnail[0];
             } else {
                 $featured = woocommerce_placeholder_img_src();
                 $thumbnail = $featured;
             }
             $title = get_the_title();
             if ($exclude_outofstock == "true" && $stock == "true" || $exclude_outofstock == "false") {
                 $output .= '<div class="ts-woocommerce-product-slide" style="' . $product_style . '" data-hash="' . $product_id . '">';
                 $output .= '<div id="ts-woocommerce-product-' . $product_id . '" class="ts-image-hover-frame ' . $image_position . ' ts-trigger-hover-adjust" style="width: 100%;">';
                 $output .= '<div id="ts-woocommerce-product-' . $product_id . '-counter" class="ts-fluid-wrapper " style="width: 100%; height: auto;">';
                 $output .= '<div id="ts-woocommerce-product-' . $product_id . '-mask" class="ts-imagehover ' . $hover_type . ' ts-trigger-hover" data-trigger="ts-trigger-hover" data-closer="" style="width: 100%; height: auto;">';
                 // Product Thumbnail
                 $output .= '<div class="ts-woocommerce-product-preview">';
                 $output .= '<img class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />';
                 $output .= '</div>';
                 // Sale Ribbon
                 if ($onsale == "true") {
                     $output .= '<div class="ts-woocommerce-product-ribbon"></div>';
                     $output .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-sale ts-ecommerce-tagsale"></i>';
                 }
                 $output .= '<div class="ts-woocommerce-product-main">';
                 $output .= '<div class="mask" style="width: 100%; display: block;">';
                 $output .= '<div id="ts-woocommerce-product-' . $product_id . '-maskcontent" class="maskcontent" style="margin: 0; padding: 0;">';
                 // Product Thubmnail
                 if ($show_image == "true") {
                     if ($link_page == "false") {
                         $output .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="nch-lightbox-media no-ajaxy" data-title="' . $title . '" rel="" href="' . $featured . '" target="' . $link_target . '">';
                         $output .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>';
                         $output .= '</a></div>';
                     } else {
                         $output .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="" data-title="' . $title . '" rel="" href="' . get_permalink() . '" target="' . $link_target . '">';
                         $output .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>';
                         $output .= '</a></div>';
                     }
                 }
                 // Product Page Link
                 if ($show_link == "true") {
                     $output .= '<div class="ts-woocommerce-link-wrapper"><a href="' . get_permalink() . '" class="ts-woocommerce-product-link" target="' . $link_target . '"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a></div>';
                 }
                 // Product Rating
                 if ($show_rating == "true") {
                     $output .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 10px 0 0 10px; float: left;">';
                     $output .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">';
                     if ($caption_show == "true" && $caption_position == "left") {
                         $output .= '<div class="ts-rating-caption" style="margin-right: 10px;">';
                         if ($rating_rtl == "false") {
                             $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>';
                         } else {
                             $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>';
                         }
                         $output .= '</div>';
                     }
                     $output .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">';
                     $output .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>';
                     $output .= '</div>';
                     if ($caption_show == "true" && $caption_position == "right") {
                         $output .= '<div class="ts-rating-caption" style="margin-left: 10px;">';
                         if ($rating_rtl == "false") {
                             $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>';
                         } else {
                             $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>';
                         }
                         $output .= '</div>';
                     }
                     $output .= '</div>';
                     $output .= '</div>';
                 }
                 // Product Price
                 if ($show_price == "true") {
                     $output .= '<div class="ts-woocommerce-product-price">';
                     $output .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>';
                     if ($product->price > 0) {
                         if ($product->price && isset($product->regular_price)) {
                             $from = $product->regular_price;
                             $to = $product->price;
                             if ($from != $to) {
                                 $output .= '<div class="ts-woocommerce-product-regular"><del>' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>';
                             } else {
                                 $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>';
                             }
                         } else {
                             $to = $product->price;
                             $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>';
                         }
                     } else {
                         $to = $product->price;
                         $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>';
                     }
                     $output .= '</div>';
                 }
                 $output .= '<div class="ts-woocommerce-product-line"></div>';
                 // Add to Cart Button (Icon)
                 if ($show_cart == "true") {
                     $output .= '<div class="ts-woocommerce-link-wrapper"><a class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a></div>';
                 }
                 // View Description Button
                 if ($show_info == "true") {
                     $output .= '<div id="ts-vcsc-modal-' . $product_id . '-trigger" style="" class="ts-vcsc-modal-' . $product_id . '-parent nch-holder ts-vcsc-font-icon ts-font-icons ts-shortcode ts-icon-align-center" style="">';
                     $output .= '<a href="#ts-vcsc-modal-' . $product_id . '" class="nch-lightbox-modal" data-title="" data-open="false" data-delay="0" data-type="html" rel="" data-effect="' . $lightbox_effect . '" data-share="0" data-duration="' . $lightbox_speed . '" data-color="' . $lightbox_backlight_selection . '">';
                     $output .= '<span class="">';
                     $output .= '<i class="ts-font-icon ts-woocommerce-product-icon ts-woocommerce-product-info ts-ecommerce-information1" style=""></i>';
                     $output .= '</span>';
                     $output .= '</a>';
                     $output .= '</div>';
                 }
                 // Product In-Stock or Unavailable
                 if ($show_stock == "true") {
                     $output .= '<div class="ts-woocommerce-product-status">';
                     if ($stock == 'false') {
                         $output .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-outofstock">' . __('Out of Stock', 'woocommerce') . '</span></div>';
                     } else {
                         if ($stock == 'true') {
                             $output .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-instock">' . __('In Stock', 'woocommerce') . '</span></div>';
                         }
                     }
                     $output .= '</div>';
                 }
                 $output .= '</div>';
                 $output .= '</div>';
                 $output .= '</div>';
                 $output .= '</div>';
                 $output .= '</div>';
                 $output .= '</div>';
                 // Product Title
                 $output .= '<h2 class="ts-woocommerce-product-title">';
                 $output .= $title;
                 $output .= '</h2>';
                 // Product Description
                 if ($show_info == "true") {
                     $output .= '<div id="ts-vcsc-modal-' . $product_id . '" class="ts-modal-content nch-hide-if-javascript" style="' . $description_style . '">';
                     $output .= '<div class="ts-modal-white-header"></div>';
                     $output .= '<div class="ts-modal-white-frame">';
                     $output .= '<div class="ts-modal-white-inner">';
                     $output .= '<h2 style="border-bottom: 1px solid #eeeeee; padding-bottom: 10px; line-height: 32px; font-size: 24px; text-align: left;">' . $title . '</h2>';
                     $output .= '<div class="ts-woocommerce-lightbox-frame" style="width: 100%; height: 32px; margin: 10px auto; padding: 0;">';
                     $output .= '<a style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>';
                     $output .= '<a href="' . get_permalink() . '" target="_parent" style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-link"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a>';
                     $output .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 0; float: right;">';
                     $output .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">';
                     if ($caption_show == "true" && $caption_position == "left") {
                         $output .= '<div class="ts-rating-caption" style="margin-right: 10px;">';
                         if ($rating_rtl == "false") {
                             $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>';
                         } else {
                             $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>';
                         }
                         $output .= '</div>';
                     }
                     $output .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">';
                     $output .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>';
                     $output .= '</div>';
                     if ($caption_show == "true" && $caption_position == "right") {
                         $output .= '<div class="ts-rating-caption" style="margin-left: 10px;">';
                         if ($rating_rtl == "false") {
                             $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>';
                         } else {
                             $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>';
                         }
                         $output .= '</div>';
                     }
                     $output .= '</div>';
                     $output .= '</div>';
                     $output .= '<div class="ts-woocommerce-product-price" style="position: inherit; margin-right: 10px; float: left; width: auto; margin-top: 0;">';
                     $output .= '<i style="color: #000000; margin: 0 10px 0 0;" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>';
                     if ($product->price > 0) {
                         if ($product->price && isset($product->regular_price)) {
                             $from = $product->regular_price;
                             $to = $product->price;
                             if ($from != $to) {
                                 $output .= '<div class="ts-woocommerce-product-regular"><del style="color: #7F0000;">' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>';
                             } else {
                                 $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>';
                             }
                         } else {
                             $to = $product->price;
                             $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>';
                         }
                     } else {
                         $to = $product->price;
                         $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>';
                     }
                     $output .= '</div>';
                     $output .= '</div>';
                     $output .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 10px auto 20px auto; width: 100%;"></div>';
                     $output .= '<img style="width: 100%; max-width: 250px; height: auto; margin: 10px auto;" class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />';
                     $output .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 20px auto 10px auto; width: 100%;"></div>';
                     $output .= '<div style="margin-top: 20px; text-align: justify;">';
                     if ($show_content == "excerpt") {
                         $output .= get_the_excerpt();
                     } else {
                         if ($show_content == "cutcharacters") {
                             $content = apply_filters('the_content', get_the_content());
                             $excerpt = TS_VCSC_TruncateHTML($content, $cutoff_characters, '...', false, true);
                             $output .= $excerpt;
                         } else {
                             if ($show_content == "complete") {
                                 $output .= get_the_content();
                             }
                         }
                     }
                     $output .= '</div>';
                     $output .= '</div>';
                     $output .= '</div>';
                     $output .= '</div>';
                 }
                 $output .= '</div>';
             }
         }
     } else {
         echo __("No products could be found.", "ts_visual_composer_extend");
     }
     $output .= '</div>';
     $output .= '</div>';
     wp_reset_postdata();
     wp_reset_query();
     echo $output;
     $myvariable = ob_get_clean();
     return $myvariable;
 }
 /**
  * Get standard product data that applies to every product type
  *
  * @since 2.1
  * @param WC_Product $product
  * @return WC_Product
  */
 private function get_product_data($product, $fields = null)
 {
     if ($fields) {
         $field_list = explode(',', $fields);
     }
     $product_data = array();
     if (!$fields || $fields && in_array('title', $field_list)) {
         $product_data['title'] = $product->get_title();
     }
     if (!$fields || $fields && in_array('id', $field_list)) {
         $product_data['id'] = (int) $product->is_type('variation') ? $product->get_variation_id() : $product->id;
     }
     if (!$fields || $fields && in_array('created_at', $field_list)) {
         $product_data['created_at'] = $this->server->format_datetime($product->get_post_data()->post_date_gmt);
     }
     if (!$fields || $fields && in_array('updated_at', $field_list)) {
         $product_data['updated_at'] = $this->server->format_datetime($product->get_post_data()->post_modified_gmt);
     }
     if (!$fields || $fields && in_array('type', $field_list)) {
         $product_data['type'] = $product->product_type;
     }
     if (!$fields || $fields && in_array('status', $field_list)) {
         $product_data['status'] = $product->get_post_data()->post_status;
     }
     if (!$fields || $fields && in_array('downloadable', $field_list)) {
         $product_data['downloadable'] = $product->is_downloadable();
     }
     if (!$fields || $fields && in_array('virtual', $field_list)) {
         $product_data['virtual'] = $product->is_virtual();
     }
     if (!$fields || $fields && in_array('permalink', $field_list)) {
         $product_data['permalink'] = $product->get_permalink();
     }
     if (!$fields || $fields && in_array('sku', $field_list)) {
         $product_data['sku'] = $product->get_sku();
     }
     if (!$fields || $fields && in_array('price', $field_list)) {
         $product_data['price'] = $product->get_price();
     }
     if (!$fields || $fields && in_array('regular_price', $field_list)) {
         $product_data['regular_price'] = $product->get_regular_price();
     }
     if (!$fields || $fields && in_array('sale_price', $field_list)) {
         $product_data['sale_price'] = $product->get_sale_price() ? $product->get_sale_price() : null;
     }
     if (!$fields || $fields && in_array('price_html', $field_list)) {
         $product_data['price_html'] = $product->get_price_html();
     }
     if (!$fields || $fields && in_array('taxable', $field_list)) {
         $product_data['taxable'] = $product->is_taxable();
     }
     if (!$fields || $fields && in_array('tax_status', $field_list)) {
         $product_data['tax_status'] = $product->get_tax_status();
     }
     if (!$fields || $fields && in_array('tax_class', $field_list)) {
         $product_data['tax_class'] = $product->get_tax_class();
     }
     if (!$fields || $fields && in_array('managing_stock', $field_list)) {
         $product_data['managing_stock'] = $product->managing_stock();
     }
     if (!$fields || $fields && in_array('stock_quantity', $field_list)) {
         $product_data['stock_quantity'] = $product->get_stock_quantity();
     }
     if (!$fields || $fields && in_array('in_stock', $field_list)) {
         $product_data['in_stock'] = $product->is_in_stock();
     }
     if (!$fields || $fields && in_array('backorders_allowed', $field_list)) {
         $product_data['backorders_allowed'] = $product->backorders_allowed();
     }
     if (!$fields || $fields && in_array('backordered', $field_list)) {
         $product_data['backordered'] = $product->is_on_backorder();
     }
     if (!$fields || $fields && in_array('sold_individually', $field_list)) {
         $product_data['sold_individually'] = $product->is_sold_individually();
     }
     if (!$fields || $fields && in_array('purchaseable', $field_list)) {
         $product_data['purchaseable'] = $product->is_purchasable();
     }
     if (!$fields || $fields && in_array('featured', $field_list)) {
         $product_data['featured'] = $product->is_featured();
     }
     if (!$fields || $fields && in_array('visible', $field_list)) {
         $product_data['visible'] = $product->is_visible();
     }
     if (!$fields || $fields && in_array('catalog_visibility', $field_list)) {
         $product_data['catalog_visibility'] = $product->visibility;
     }
     if (!$fields || $fields && in_array('on_sale', $field_list)) {
         $product_data['on_sale'] = $product->is_on_sale();
     }
     if (!$fields || $fields && in_array('product_url', $field_list)) {
         $product_data['product_url'] = $product->is_type('external') ? $product->get_product_url() : '';
     }
     if (!$fields || $fields && in_array('button_text', $field_list)) {
         $product_data['button_text'] = $product->is_type('external') ? $product->get_button_text() : '';
     }
     if (!$fields || $fields && in_array('weight', $field_list)) {
         $product_data['weight'] = $product->get_weight() ? $product->get_weight() : null;
     }
     if (!$fields || $fields && in_array('dimensions', $field_list)) {
         $product_data['dimensions'] = array('length' => $product->length, 'width' => $product->width, 'height' => $product->height, 'unit' => get_option('woocommerce_dimension_unit'));
     }
     if (!$fields || $fields && in_array('shipping_required', $field_list)) {
         $product_data['shipping_required'] = $product->needs_shipping();
     }
     if (!$fields || $fields && in_array('shipping_taxable', $field_list)) {
         $product_data['shipping_taxable'] = $product->is_shipping_taxable();
     }
     if (!$fields || $fields && in_array('shipping_class', $field_list)) {
         $product_data['shipping_class'] = $product->get_shipping_class();
     }
     if (!$fields || $fields && in_array('shipping_class_id', $field_list)) {
         $product_data['shipping_class_id'] = 0 !== $product->get_shipping_class_id() ? $product->get_shipping_class_id() : null;
     }
     if (!$fields || $fields && in_array('description', $field_list)) {
         $product_data['description'] = wpautop(do_shortcode($product->get_post_data()->post_content));
     }
     if (!$fields || $fields && in_array('short_description', $field_list)) {
         $product_data['short_description'] = apply_filters('woocommerce_short_description', $product->get_post_data()->post_excerpt);
     }
     if (!$fields || $fields && in_array('reviews_allowed', $field_list)) {
         $product_data['reviews_allowed'] = 'open' === $product->get_post_data()->comment_status;
     }
     if (!$fields || $fields && in_array('average_rating', $field_list)) {
         $product_data['average_rating'] = wc_format_decimal($product->get_average_rating(), 2);
     }
     if (!$fields || $fields && in_array('rating_count', $field_list)) {
         $product_data['rating_count'] = (int) $product->get_rating_count();
     }
     if (!$fields || $fields && in_array('related_ids', $field_list)) {
         $product_data['related_ids'] = array_map('absint', array_values($product->get_related()));
     }
     if (!$fields || $fields && in_array('upsell_ids', $field_list)) {
         $product_data['upsell_ids'] = array_map('absint', $product->get_upsells());
     }
     if (!$fields || $fields && in_array('cross_sell_ids', $field_list)) {
         $product_data['cross_sell_ids'] = array_map('absint', $product->get_cross_sells());
     }
     if (!$fields || $fields && in_array('parent_id', $field_list)) {
         $product_data['parent_id'] = $product->post->post_parent;
     }
     if (!$fields || $fields && in_array('categories', $field_list)) {
         $product_data['categories'] = wp_get_post_terms($product->id, 'product_cat', array('fields' => 'names'));
     }
     if (!$fields || $fields && in_array('tags', $field_list)) {
         $product_data['tags'] = wp_get_post_terms($product->id, 'product_tag', array('fields' => 'names'));
     }
     if (!$fields || $fields && in_array('images', $field_list)) {
         $product_data['images'] = $this->get_images($product);
     }
     if (!$fields || $fields && in_array('featured_src', $field_list)) {
         $product_data['featured_src'] = (string) wp_get_attachment_url(get_post_thumbnail_id($product->is_type('variation') ? $product->variation_id : $product->id));
     }
     if (!$fields || $fields && in_array('attributes', $field_list)) {
         $product_data['attributes'] = $this->get_attributes($product);
     }
     if (!$fields || $fields && in_array('downloads', $field_list)) {
         $product_data['downloads'] = $this->get_downloads($product);
     }
     if (!$fields || $fields && in_array('download_limit', $field_list)) {
         $product_data['download_limit'] = (int) $product->download_limit;
     }
     if (!$fields || $fields && in_array('download_expiry', $field_list)) {
         $product_data['download_expiry'] = (int) $product->download_expiry;
     }
     if (!$fields || $fields && in_array('download_type', $field_list)) {
         $product_data['download_type'] = $product->download_type;
     }
     if (!$fields || $fields && in_array('purchase_note', $field_list)) {
         $product_data['purchase_note'] = wpautop(do_shortcode(wp_kses_post($product->purchase_note)));
     }
     if (!$fields || $fields && in_array('total_sales', $field_list)) {
         $product_data['total_sales'] = metadata_exists('post', $product->id, 'total_sales') ? (int) get_post_meta($product->id, 'total_sales', true) : 0;
     }
     if (!$fields || $fields && in_array('variations', $field_list)) {
         $product_data['variations'] = array();
     }
     if (!$fields || $fields && in_array('parent', $field_list)) {
         $product_data['parent'] = array();
     }
     if (!$fields || $fields && in_array('grouped_products', $field_list)) {
         $product_data['grouped_products'] = array();
     }
     if (!$fields || $fields && in_array('menu_order', $field_list)) {
         $product_data['menu_order'] = $product->post->menu_order;
     }
     return $product_data;
 }
        function TS_VCSC_WooCommerce_Ticker_Basic_Function($atts, $content = null)
        {
            global $VISUAL_COMPOSER_EXTENSIONS;
            global $product;
            global $woocommerce;
            ob_start();
            wp_enqueue_script('ts-extend-newsticker');
            wp_enqueue_style('ts-font-ecommerce');
            wp_enqueue_style('ts-font-teammatess');
            if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") {
                wp_enqueue_style('ts-extend-animations');
                wp_enqueue_style('ts-visual-composer-extend-front');
                wp_enqueue_script('ts-visual-composer-extend-front');
            }
            extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'post_type' => 'product', 'date_format' => 'F j, Y', 'time_format' => 'l, g:i A', 'limit_posts' => 'true', 'limit_by' => 'category', 'limit_term' => '', 'filter_menu' => 'true', 'layout_menu' => 'true', 'sort_menu' => 'false', 'directions_menu' => 'false', 'filter_by' => 'category', 'ticker_direction' => 'up', 'ticker_speed' => 3000, 'ticker_break' => 480, 'ticker_border_type' => '', 'ticker_border_thick' => 1, 'ticker_border_color' => '#ededed', 'ticker_border_radius' => '', 'ticker_auto' => 'false', 'ticker_hover' => 'true', 'ticker_controls' => 'true', 'ticker_symbol' => 'false', 'ticker_icon' => '', 'ticker_paint' => '#ffffff', 'ticker_title' => 'true', 'ticker_header' => 'Latest Products', 'ticker_background' => '#D10000', 'ticker_color' => '#ffffff', 'ticker_type' => 'true', 'ticker_image' => 'true', 'ticker_price' => 'true', 'ticker_cart' => 'true', 'ticker_add_item' => 'Add This Item', 'ticker_remove_item' => 'Remove This Item', 'ticker_rating' => 'true', 'ticker_stock' => 'false', 'ticker_side' => 'left', 'ticker_fixed' => 'false', 'ticker_position' => 'top', 'ticker_adjustment' => 0, 'ticker_target' => '_parent', 'posts_limit' => 25, 'rating_maximum' => 5, 'rating_size' => 20, 'rating_quarter' => 'true', 'rating_name' => 'true', 'rating_auto' => 'true', 'rating_position' => 'top', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => 'ts-ecommerce-starfull1', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'true', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts));
            $woo_random = mt_rand(999999, 9999999);
            if (!empty($el_id)) {
                $woo_ticker_id = $el_id;
            } else {
                $woo_ticker_id = 'ts-vcsc-woocommerce-ticker-' . $woo_random;
            }
            $output = '';
            // Check for Front End Editor
            if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") {
                $frontend_edit = 'true';
                $ticker_fixed = 'false';
                $ticker_auto = 'false';
            } else {
                $frontend_edit = 'false';
                $ticker_fixed = $ticker_fixed;
                $ticker_auto = $ticker_auto;
            }
            $meta_query = '';
            // Recent Products
            if ($selection == "recent_products") {
                $meta_query = WC()->query->get_meta_query();
            }
            // Featured Products
            if ($selection == "featured_products") {
                $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes'));
            }
            // Top Rated Products
            if ($selection == "top_rated_products") {
                add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses'));
                $meta_query = WC()->query->get_meta_query();
            }
            // Final Query Arguments
            $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query);
            // Products on Sale
            if ($selection == "sale_products") {
                $product_ids_on_sale = woocommerce_get_product_ids_on_sale();
                $meta_query = array();
                $meta_query[] = $woocommerce->query->visibility_meta_query();
                $meta_query[] = $woocommerce->query->stock_status_meta_query();
                $args['meta_query'] = $meta_query;
                $args['post__in'] = $product_ids_on_sale;
            }
            // Best Selling Products
            if ($selection == "best_selling_products") {
                $args['meta_key'] = 'total_sales';
                $args['orderby'] = 'meta_value_num';
                $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'));
            }
            // Products in Single Category
            if ($selection == "product_category") {
                $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN'));
            }
            // Products in Multiple Categories
            if ($selection == "product_categories") {
                $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN'));
            }
            // Start WordPress Query
            $loop = new WP_Query($args);
            if ($ticker_fixed == "true") {
                $newsticker_class = 'ts-newsticker-fixed';
                $newsticker_position = 'ts-newsticker-' . $ticker_position;
                if ($ticker_position == "top") {
                    $newsticker_style = 'top: ' . $ticker_adjustment . 'px;';
                } else {
                    $newsticker_style = 'bottom: ' . $ticker_adjustment . 'px;';
                }
                $margin_top = 0;
                $margin_bottom = 0;
            } else {
                $newsticker_class = 'ts-newsticker-standard';
                $newsticker_position = '';
                $newsticker_style = '';
            }
            if ($ticker_border_type != '') {
                $newsticker_border = 'border: ' . $ticker_border_thick . 'px ' . $ticker_border_type . ' ' . $ticker_border_color . ';';
            } else {
                $newsticker_border = '';
            }
            if ($ticker_side == "left") {
                $newsticker_elements = 'ts-newsticker-elements-left';
            } else {
                $newsticker_elements = 'ts-newsticker-elements-right';
            }
            if ($ticker_title == "false") {
                $newsticker_header = 'left: 0;';
                $newsticker_controls = 'right: 10px;';
            } else {
                $newsticker_header = '';
                $newsticker_controls = '';
            }
            if (function_exists('vc_shortcode_custom_css_class')) {
                $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $el_class . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Ticker_Basic', $atts);
            } else {
                $css_class = $slider_class . ' ' . $el_class;
            }
            $output .= '<div id="' . $woo_ticker_id . '" class="ts-newsticker-parent ' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . ';">';
            // Create Individual Post Output
            $postCounter = 0;
            $postMonths = array();
            if ($loop->have_posts()) {
                $output .= '<div id="ts-newsticker-oneliner-' . $woo_random . '"
						class="ts-newsticker-oneliner ' . $newsticker_class . ' ' . $newsticker_position . ' ' . $ticker_border_radius . '"
						style="' . $newsticker_style . ' ' . $newsticker_border . '"
						data-ticker="ts-newsticker-ticker-' . $woo_random . '"
						data-controls="ts-newsticker-controls-' . $woo_random . '"
						data-navigation="' . $ticker_controls . '"
						data-break="' . $ticker_break . '"
						data-auto="' . $ticker_auto . '"
						data-speed="' . $ticker_speed . '"
						data-hover="' . $ticker_hover . '"
						data-direction="' . $ticker_direction . '"
						data-parent="' . $woo_ticker_id . '"
						data-side="' . $ticker_side . '"
						data-header="ts-newsticker-header-' . $woo_random . '"
						data-next="ts-newsticker-controls-next-' . $woo_random . '"
						data-prev="ts-newsticker-controls-prev-' . $woo_random . '"
						data-play="ts-newsticker-controls-play-' . $woo_random . '"
						data-stop="ts-newsticker-controls-stop-' . $woo_random . '">';
                $output .= '<div class="ts-newsticker-elements-frame ' . $newsticker_elements . ' ' . $ticker_border_radius . '" style="">';
                // Add Navigation Controls
                $output .= '<div id="ts-newsticker-controls-' . $woo_random . '" class="ts-newsticker-controls" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . ' ' . $newsticker_controls . '">';
                $output .= '<div id="ts-newsticker-controls-next-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>';
                $output .= '<div id="ts-newsticker-controls-prev-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>';
                $output .= '<div id="ts-newsticker-controls-stop-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: block;" : "display: none;") . '"><span class="ts-ecommerce-pause"></span></div>';
                $output .= '<div id="ts-newsticker-controls-play-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: none;" : "display: block;") . '"><span class="ts-ecommerce-play"></span></div>';
                $output .= '</div>';
                if ($ticker_side == "left" && $ticker_title == "true") {
                    $output .= '<div id="ts-newsticker-header-' . $woo_random . '" class="header ' . $ticker_border_radius . '" style="background: ' . $ticker_background . '; color: ' . $ticker_color . '; left: 0;">';
                    if ($ticker_icon != '' && $ticker_icon != 'transparent' && $ticker_symbol == "true") {
                        $output .= '<i class="ts-font-icon ' . $ticker_icon . '" style="color: ' . $ticker_paint . '"></i>';
                    }
                    $output .= '<span>' . $ticker_header . '</span>';
                    $output .= '</div>';
                }
                $output .= '<ul id="ts-newsticker-ticker-' . $woo_random . '" class="newsticker ' . $ticker_border_radius . '" style="' . $newsticker_header . '">';
                while ($loop->have_posts()) {
                    $loop->the_post();
                    $postCounter++;
                    if ($postCounter < $posts_limit + 1) {
                        $postAttributes = 'data-full="' . get_post_time($date_format) . '" data-time="' . get_post_time($time_format) . '" data-author="' . get_the_author() . '" data-date="' . get_post_time('U') . '" data-modified="' . get_the_modified_time('U') . '" data-title="' . get_the_title() . '" data-comments="' . get_comments_number() . '" data-id="' . get_the_ID() . '"';
                        $product_id = get_the_ID();
                        $product_title = get_the_title($product_id);
                        $post = get_post($product_id);
                        $product = new WC_Product($product_id);
                        $attachment_ids = $product->get_gallery_attachment_ids();
                        $price = $product->get_price_html();
                        $product_sku = $product->get_sku();
                        $attributes = $product->get_attributes();
                        $stock = $product->is_in_stock() ? 'true' : 'false';
                        $onsale = $product->is_on_sale() ? 'true' : 'false';
                        // Rating Settings
                        $rating_html = $product->get_rating_html();
                        $rating = $product->get_average_rating();
                        if ($rating == '') {
                            $rating = 0;
                        }
                        if ($rating_quarter == "true") {
                            $rating_value = floor($rating * 4) / 4;
                        } else {
                            $rating_value = $rating;
                        }
                        $rating_value = number_format($rating_value, 2, $caption_digits, '');
                        if ($rating_rtl == "false") {
                            $rating_width = $rating_value / $rating_maximum * 100;
                        } else {
                            $rating_width = 100 - $rating_value / $rating_maximum * 100;
                        }
                        if ($rating_symbol == "other") {
                            if ($rating_icon == "ts-ecommerce-starfull1") {
                                $rating_class = 'ts-rating-stars-star1';
                            } else {
                                if ($rating_icon == "ts-ecommerce-starfull2") {
                                    $rating_class = 'ts-rating-stars-star2';
                                } else {
                                    if ($rating_icon == "ts-ecommerce-starfull3") {
                                        $rating_class = 'ts-rating-stars-star3';
                                    } else {
                                        if ($rating_icon == "ts-ecommerce-starfull4") {
                                            $rating_class = 'ts-rating-stars-star4';
                                        } else {
                                            if ($rating_icon == "ts-ecommerce-heartfull") {
                                                $rating_class = 'ts-rating-stars-heart1';
                                            } else {
                                                if ($rating_icon == "ts-ecommerce-heart") {
                                                    $rating_class = 'ts-rating-stars-heart2';
                                                } else {
                                                    if ($rating_icon == "ts-ecommerce-thumbsup") {
                                                        $rating_class = 'ts-rating-stars-thumb';
                                                    } else {
                                                        if ($rating_icon == "ts-ecommerce-ribbon4") {
                                                            $rating_class = 'ts-rating-stars-ribbon';
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        } else {
                            $rating_class = 'ts-rating-stars-smile';
                        }
                        if ($rating_value >= 0 && $rating_value <= 1) {
                            $caption_class = 'ts-label-danger';
                            $caption_background = 'background-color: ' . $caption_danger . ';';
                        } else {
                            if ($rating_value > 1 && $rating_value <= 2) {
                                $caption_class = 'ts-label-warning';
                                $caption_background = 'background-color: ' . $caption_warning . ';';
                            } else {
                                if ($rating_value > 2 && $rating_value <= 3) {
                                    $caption_class = 'ts-label-info';
                                    $caption_background = 'background-color: ' . $caption_info . ';';
                                } else {
                                    if ($rating_value > 3 && $rating_value <= 4) {
                                        $caption_class = 'ts-label-primary';
                                        $caption_background = 'background-color: ' . $caption_primary . ';';
                                    } else {
                                        if ($rating_value > 4 && $rating_value <= 5) {
                                            $caption_class = 'ts-label-success';
                                            $caption_background = 'background-color: ' . $caption_success . ';';
                                        }
                                    }
                                }
                            }
                        }
                        // Check if Product already in Cart
                        $cart_page_id = wc_get_page_id('cart');
                        $already_added = "false";
                        foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) {
                            if ($product_id == $cart_item['product_id']) {
                                $already_added = "true";
                                $cart_link = apply_filters('woocommerce_cart_item_remove_link', sprintf('<a class="ts-newsticker-product-remove" href="%s" title="%s" rel="" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-newsticker-product-cart ts-woocommerce-product-cart ts-ecommerce-cross2"></i></a>', esc_url($woocommerce->cart->get_remove_url($cart_item_key)), $ticker_remove_item), $cart_item_key);
                            }
                        }
                        if ($already_added == "false") {
                            $cart_link = '<span class="ts-woocommerce-link-wrapper"><a class="ts-newsticker-product-purchase" href="?add-to-cart=' . $product_id . '" title="' . $ticker_add_item . '" rel="" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-newsticker-product-cart ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a></span>';
                        }
                        $output .= '<li ' . $postAttributes . '>';
                        if ($ticker_image == 'true') {
                            if ('' != get_the_post_thumbnail()) {
                                $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail');
                                $output .= '<img class="ts-newsticker-image" src="' . $thumbnail[0] . '" style="">';
                            }
                        }
                        $output .= '<span class="ts-woocommerce-link-wrapper"><a href="' . get_permalink() . '" target="' . $ticker_target . '">';
                        $output .= get_the_title();
                        $output .= '</a></span>';
                        // Product Price
                        if ($ticker_price == "true") {
                            $output .= '<span class="ts-newsticker-pricetag" style="">';
                            if ($product->price > 0) {
                                if ($product->price && isset($product->regular_price)) {
                                    $from = $product->regular_price;
                                    $to = $product->price;
                                    if ($from != $to) {
                                        $output .= '<span class="ts-newsticker-product-regular" style="float: none;"><del>' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </span><span class="ts-newsticker-product-special" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>';
                                    } else {
                                        $output .= '<span class="ts-newsticker-product-current" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>';
                                    }
                                } else {
                                    $to = $product->price;
                                    $output .= '<span class="ts-newsticker-product-current" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>';
                                }
                            } else {
                                $to = $product->price;
                                $output .= '<span class="ts-newsticker-product-current" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>';
                            }
                            $output .= '</span>';
                        }
                        // Sale Ribbon
                        if ($onsale == "true") {
                            $output .= '<i style="position: inherit" class="ts-newsticker-product-sale ts-woocommerce-product-sale ts-ecommerce-tagsale"></i>';
                        }
                        // Product Rating
                        if ($ticker_rating == "true") {
                            $output .= '<span class="ts-rating-stars-frame" data-auto="false" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 10px 0 0 10px; float: none;">';
                            $output .= '<span class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">';
                            if ($caption_show == "true" && $caption_position == "left") {
                                $output .= '<span class="ts-rating-caption" style="margin-right: 10px;">';
                                if ($rating_rtl == "false") {
                                    $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>';
                                } else {
                                    $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>';
                                }
                                $output .= '</span>';
                            }
                            $output .= '<span class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">';
                            $output .= '<span class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></span>';
                            $output .= '</span>';
                            if ($caption_show == "true" && $caption_position == "right") {
                                $output .= '<span class="ts-rating-caption" style="margin-left: 10px;">';
                                if ($rating_rtl == "false") {
                                    $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>';
                                } else {
                                    $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>';
                                }
                                $output .= '</span>';
                            }
                            $output .= '</span>';
                            $output .= '</span>';
                        }
                        // Add to Cart Icon
                        if ($ticker_cart == "true") {
                            //$output .= '<a class="ts-newsticker-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-newsticker-product-cart ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>';
                            $output .= $cart_link;
                        }
                        // Product In-Stock or Unavailable
                        if ($ticker_stock == "true") {
                            $output .= '<span class="ts-woocommerce-product-status" style="margin-left: 10px;">';
                            if ($stock == 'false') {
                                $output .= '<span class="ts-woocommerce-product-stock" style="position: inherit;"><span class="ts-woocommerce-product-outofstock">' . __('Out of Stock', 'woocommerce') . '</span></span>';
                            } else {
                                if ($stock == 'true') {
                                    $output .= '<span class="ts-woocommerce-product-stock" style="position: inherit;"><span class="ts-woocommerce-product-instock">' . __('In Stock', 'woocommerce') . '</span></span>';
                                }
                            }
                            $output .= '</span>';
                        }
                        $output .= '</li>';
                    }
                }
                $output .= '</ul>';
                if ($ticker_side == "right" && $ticker_title == "true") {
                    $output .= '<div id="ts-newsticker-header-' . $woo_random . '" class="header ' . $ticker_border_radius . '" style="background: ' . $ticker_background . '; color: ' . $ticker_color . '; right: 0;">';
                    if ($ticker_icon != '' && $ticker_icon != 'transparent' && $ticker_symbol == "true") {
                        $output .= '<i class="ts-font-icon ' . $ticker_icon . '" style="color: ' . $ticker_paint . '"></i>';
                    }
                    $output .= '<span>' . $ticker_header . '</span>';
                    $output .= '</div>';
                }
                $output .= '</div>';
                $output .= '</div>';
            } else {
                echo __("No products could be found.", "ts_visual_composer_extend");
            }
            $output .= '</div>';
            wp_reset_postdata();
            wp_reset_query();
            echo $output;
            $myvariable = ob_get_clean();
            return $myvariable;
        }
 /**
  * True if the product is in stock and all bundled items are in stock.
  *
  * @return bool
  */
 public function is_in_stock()
 {
     $is_in_stock = parent::is_in_stock();
     if ($is_in_stock) {
         if (is_woocommerce()) {
             if (!$this->is_synced()) {
                 $this->sync_bundle();
             }
             if (!$this->all_items_in_stock()) {
                 $is_in_stock = false;
             }
         }
     }
     return $is_in_stock;
 }
 function is_in_stock()
 {
     if (!is_admin()) {
         if ($this->availability['class'] == 'out-of-stock') {
             return false;
         }
     }
     return parent::is_in_stock();
 }
 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;
 }
function WooComposer_Loop_style04($atts, $element)
{
    global $woocommerce;
    $product_style = $display_elements = $quick_view_style = $img_animate = $text_align = $color_heading = $color_categories = $color_price = '';
    $color_rating = $color_rating_bg = $color_quick_bg = $color_quick = $color_cart_bg = $color_cart = $color_product_desc = $advanced_opts = '';
    $color_product_desc_bg = $size_title = $size_cat = $size_price = $color_on_sale = $color_on_sale_bg = $label_on_sale = $product_animation = '';
    $disp_type = $category = $output = $product_style = $border_style = $border_color = $border_size = $border_radius = $lazy_images = $pagination = '';
    $sale_price = $shortcode = $on_sale_alignment = $on_sale_style = $product_img_disp = '';
    extract(shortcode_atts(array("disp_type" => "", "category" => "", "shortcode" => "", "product_style" => "style01", "display_elements" => "", "quick_view_style" => "expandable", "label_on_sale" => "Sale!", "text_align" => "left", "img_animate" => "rotate-clock", "pagination" => "", "color_heading" => "", "color_categories" => "", "color_price" => "", "color_rating" => "", "color_rating_bg" => "", "color_quick_bg" => "", "color_quick" => "", "color_cart_bg" => "", "color_on_sale_bg" => "", "color_on_sale" => "", "color_cart" => "", "color_product_desc" => "", "color_product_desc_bg" => "", "size_title" => "", "size_cat" => "", "size_price" => "", "border_style" => "", "border_color" => "", "border_size" => "", "border_radius" => "", "product_animation" => "", "lazy_images" => "", "advanced_opts" => "", "sale_price" => "", "on_sale_style" => "wcmp-sale-circle", "on_sale_alignment" => "wcmp-sale-right", "product_img_disp" => "single"), $atts));
    $output = $heading_style = $cat_style = $price_style = $cart_style = $cart_bg_style = $view_style = $view_bg_style = $rating_style = '';
    $desc_style = $label_style = $on_sale = $class = $style = $border = $desc_style = $sale_price_size = '';
    $image_size = apply_filters('single_product_large_thumbnail_size', 'shop_single');
    $img_animate = 'wcmp-img-' . $img_animate;
    if ($sale_price !== '') {
        $sale_price_size = 'font-size:' . $sale_price . 'px;';
    }
    if ($border_style !== '') {
        $border .= 'border:' . $border_size . 'px ' . $border_style . ' ' . $border_color . ';';
        $border .= 'border-radius:' . $border_radius . 'px;';
    }
    if ($color_product_desc_bg !== '') {
        $desc_style .= 'background:' . $color_product_desc_bg . ';';
    }
    if ($color_product_desc !== '') {
        $desc_style .= 'color:' . $color_product_desc . ';';
    }
    $columns = 3;
    $display_type = $disp_type;
    if ($color_heading !== "") {
        $heading_style = 'color:' . $color_heading . ';';
    }
    if ($size_title !== "") {
        $heading_style .= 'font-size:' . $size_title . 'px;';
    }
    if ($color_categories !== "") {
        $cat_style = 'color:' . $color_categories . ';';
    }
    if ($size_cat !== "") {
        $cat_style .= 'font-size:' . $size_cat . 'px;';
    }
    if ($color_price !== "") {
        $price_style = 'color:' . $color_price . ';';
    }
    if ($size_price !== "") {
        $price_style .= 'font-size:' . $size_price . 'px;';
    }
    if ($color_rating !== "") {
        $rating_style .= 'color:' . $color_rating . ';';
    }
    if ($color_rating_bg !== "") {
        $rating_style .= 'background:' . $color_rating_bg . ';';
    }
    if ($color_quick_bg !== "") {
        $view_bg_style = 'background:' . $color_quick_bg . ';';
    }
    if ($color_quick !== "") {
        $view_style = 'color:' . $color_quick . ';';
    }
    if ($color_cart_bg !== "") {
        $cart_bg_style = 'background:' . $color_cart_bg . ';';
    }
    if ($color_cart !== "") {
        $cart_style = 'color:' . $color_cart . ';';
    }
    if ($color_on_sale_bg !== "") {
        $label_style = 'background:' . $color_on_sale_bg . ';';
    }
    if ($color_on_sale !== "") {
        $label_style .= 'color:' . $color_on_sale . ';';
    }
    $elemets = explode(",", $display_elements);
    if ($element == "grid") {
        $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    } else {
        $paged = 1;
    }
    $post_count = '12';
    /* $output .= do_shortcode($content); */
    if ($shortcode !== '') {
        $new_shortcode = rawurldecode(base64_decode(strip_tags($shortcode)));
    }
    $pattern = get_shortcode_regex();
    $shortcode_str = $short_atts = '';
    preg_match_all("/" . $pattern . "/", $new_shortcode, $matches);
    $shortcode_str = str_replace('"', '', str_replace(" ", "&", trim($matches[3][0])));
    $short_atts = parse_str($shortcode_str);
    //explode("&",$shortcode_str);
    if (isset($matches[2][0])) {
        $display_type = $matches[2][0];
    } else {
        $display_type = '';
    }
    if (!isset($columns)) {
        $columns = '4';
    }
    if (isset($per_page)) {
        $post_count = $per_page;
    }
    if (isset($number)) {
        $post_count = $number;
    }
    if (!isset($order)) {
        $order = 'asc';
    }
    if (!isset($orderby)) {
        $orderby = 'date';
    }
    if (!isset($category)) {
        $category = '';
    }
    if (!isset($ids)) {
        $ids = '';
    }
    if ($ids) {
        $ids = explode(',', $ids);
        $ids = array_map('trim', $ids);
    }
    $col = $columns;
    if ($columns == "2") {
        $columns = 6;
    } elseif ($columns == "3") {
        $columns = 4;
    } elseif ($columns == "4") {
        $columns = 3;
    }
    $meta_query = '';
    if ($display_type == "recent_products") {
        $meta_query = WC()->query->get_meta_query();
    }
    if ($display_type == "featured_products") {
        $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes'));
    }
    if ($display_type == "top_rated_products") {
        add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses'));
        $meta_query = WC()->query->get_meta_query();
    }
    $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $post_count, 'orderby' => $orderby, 'order' => $order, 'paged' => $paged, 'meta_query' => $meta_query);
    if ($display_type == "sale_products") {
        $product_ids_on_sale = woocommerce_get_product_ids_on_sale();
        $meta_query = array();
        $meta_query[] = $woocommerce->query->visibility_meta_query();
        $meta_query[] = $woocommerce->query->stock_status_meta_query();
        $args['meta_query'] = $meta_query;
        $args['post__in'] = $product_ids_on_sale;
    }
    if ($display_type == "best_selling_products") {
        $args['meta_key'] = 'total_sales';
        $args['orderby'] = 'meta_value_num';
        $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'));
    }
    if ($display_type == "product_category") {
        $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN'));
    }
    if ($display_type == "product_categories") {
        $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => $ids, 'field' => 'term_id', 'operator' => 'IN'));
    }
    $test = '';
    if (vc_is_inline()) {
        $test = "wcmp_vc_inline";
    }
    if ($product_animation == '') {
        $product_animation = 'no-animation';
    } else {
        $style .= 'opacity:1;';
    }
    if ($element == "grid") {
        $class = 'vc_span' . $columns . ' ';
    }
    $output .= '<div class="woocomposer ' . $test . '" data-columns="' . $col . '">';
    $query = new WP_Query($args);
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            $product_id = get_the_ID();
            $uid = uniqid();
            $output .= '<div id="product-' . $uid . '" style="' . $style . '" class="' . $class . ' wpb_column column_container wooproduct" data-animation="animated ' . $product_animation . '">';
            if ($element == 'carousel') {
                $output .= '<div class="wcmp-carousel-item">';
            }
            $product_title = get_the_title($product_id);
            $post = get_post($product_id);
            $product_desc = get_post($product_id)->post_excerpt;
            $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
            $product = new WC_Product($product_id);
            $attachment_ids = $product->get_gallery_attachment_ids();
            $price = $product->get_price_html();
            $rating = $product->get_rating_html();
            $attributes = $product->get_attributes();
            $stock = $product->is_in_stock() ? 'InStock' : 'OutOfStock';
            if ($product->is_on_sale()) {
                $on_sale = apply_filters('woocommerce_sale_flash', $label_on_sale, $post, $product);
            } else {
                $on_sale = '';
            }
            if ($quick_view_style == "expandable") {
                $quick_view_class = 'quick-view-loop';
            } else {
                $quick_view_class = 'quick-view-loop-popup';
            }
            $cat_count = sizeof(get_the_terms($product_id, 'product_cat'));
            $tag_count = sizeof(get_the_terms($product_id, 'product_tag'));
            $categories = $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>');
            $tags = $product->get_tags(', ', '<span class="tagged_as">' . _n('', '', $tag_count, 'woocommerce') . ' ', '.</span>');
            $output .= "\n" . '<div class="wcmp-product woocommerce wcmp-' . $product_style . ' ' . $img_animate . '" style="' . $border . ' ' . $desc_style . '">';
            $output .= "\n\t" . '<div class="wcmp-product-image">';
            if (empty($attachment_ids) && count($attachment_ids) > 1 && $product_img_disp == "carousel") {
                $uniqid = uniqid();
                $output .= '<div class="wcmp-single-image-carousel carousel-in-loop">';
                $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
                if ($lazy_images == "enable") {
                    $src = plugins_url('../assets/img/loader.gif', __FILE__);
                } else {
                    $src = $product_img[0];
                }
                $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>';
                foreach ($attachment_ids as $attachment_id) {
                    $product_img = wp_get_attachment_image_src($attachment_id, $image_size);
                    if ($lazy_images == "enable") {
                        $src = plugins_url('../assets/img/loader.gif', __FILE__);
                    } else {
                        $src = $product_img[0];
                    }
                    $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>';
                }
                $output .= '</div>';
            } else {
                $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
                if ($lazy_images == "enable") {
                    $src = plugins_url('../assets/img/loader.gif', __FILE__);
                } else {
                    $src = $product_img[0];
                }
                $output .= '<a href="' . get_permalink($product_id) . '"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></a>';
            }
            if ($stock == 'OutOfStock') {
                $output .= "\n" . '<span class="wcmp-out-stock">' . __('Out Of Stock!', 'woocomposer') . '</span>';
            }
            if ($on_sale !== '') {
                $output .= "\n" . '<div class="wcmp-onsale ' . $on_sale_alignment . ' ' . $on_sale_style . '"><span class="onsale" style="' . $label_style . ' ' . $sale_price_size . '">' . $on_sale . '</span></div>';
            }
            $output .= '<div class="wcmp-add-to-cart" style="' . $cart_bg_style . '"><a style="' . $cart_style . '" title="Add to Cart" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-product_id="' . $product_id . '" data-product_sku="" class="add_to_cart_button product_type_simple"><i class="wooicon-cart4"></i></a></div>';
            if (in_array("quick", $elemets)) {
                $output .= '<div class="wcmp-quick-view ' . $quick_view_class . '" style="' . $view_bg_style . '"><a style="' . $view_style . '" title="Quick View" href="' . get_permalink($product_id) . '"><i class="wooicon-plus32"></i></a></div>';
            }
            if (in_array("reviews", $elemets)) {
                $output .= "\n" . '<div class="wcmp-star-ratings" style="' . $rating_style . '">' . $rating . '</div>';
            }
            $output .= '</div>';
            $output .= "\n\t" . '<div class="wcmp-product-desc">';
            $output .= '<a href="' . get_permalink($product_id) . '">';
            $output .= "\n\t\t" . '<h2 style="' . $heading_style . '">' . $product_title . '</h2>';
            $output .= '</a>';
            if (in_array("category", $elemets)) {
                $output .= '<h5 style="' . $cat_style . '">';
                if ($categories !== '') {
                    $output .= $categories;
                    $output .= $tags;
                }
                $output .= '</h5>';
            }
            $output .= "\n\t\t" . '<div class="wcmp-price"><span class="price" style="' . $price_style . '">' . $price . '</span></div>';
            if (in_array("description", $elemets)) {
                $output .= "\n\t\t" . '<div class="wcmp-product-content" style="' . $desc_style . '">' . $product_desc . '</div>';
            }
            $output .= "\n\t" . '</div>';
            $output .= "\n\t" . '</div>';
            if (in_array("quick", $elemets)) {
                $output .= '<div class="wcmp-quick-view-wrapper woocommerce" data-columns="' . $col . '">';
                if ($quick_view_style !== "expandable") {
                    $output .= '<div class="wcmp-quick-view-wrapper woocommerce product">';
                    $output .= '<div class="wcmp-close-single"><i class="wooicon-cross2"></i></div>';
                }
                $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
                if ($lazy_images == "enable") {
                    $src = plugins_url('../assets/img/loader.gif', __FILE__);
                } else {
                    $src = $product_img[0];
                }
                $output .= '<div class="wcmp-single-image wcmp-quickview-img images"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div>';
                if ($quick_view_style !== "expandable") {
                    $output .= '<div class="wcmp-product-content-single">';
                } else {
                    $output .= '<div class="wcmp-product-content">';
                }
                ob_start();
                do_action('woocommerce_single_product_summary');
                $output .= ob_get_clean();
                $output .= '</div>';
                $output .= '<div class="clear"></div>';
                if ($quick_view_style !== "expandable") {
                    $output .= '</div>';
                }
                $output .= '</div>';
            }
            $output .= "\n" . '</div>';
            if ($element == 'carousel') {
                $output .= "\n\t" . '</div>';
            }
        }
    }
    if ($pagination == "enable") {
        $output .= '<div class="wcmp-paginate">';
        $output .= woocomposer_pagination($query->max_num_pages);
        $output .= '</div>';
    }
    $output .= '</div>';
    if ($display_type == "top_rated_products") {
        remove_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses'));
    }
    wp_reset_postdata();
    return $output;
}
示例#17
0
 /**
  * Add a product to the cart
  *
  * @param   string	product_id	contains the id of the product to add to the cart
  * @param   string	quantity	contains the quantity of the item to add
  * @param   int     variation_id
  * @param   array   variation attribute values
  */
 function add_to_cart($product_id, $quantity = 1, $variation_id = '', $variation = '')
 {
     global $woocommerce;
     if ($quantity < 1) {
         return false;
     }
     // Load cart item data - may be added by other plugins
     $cart_item_data = (array) apply_filters('woocommerce_add_cart_item_data', array(), $product_id);
     // Generate a ID based on product ID, variation ID, variation data, and other cart item data
     $cart_id = $this->generate_cart_id($product_id, $variation_id, $variation, $cart_item_data);
     // See if this product and its options is already in the cart
     $cart_item_key = $this->find_product_in_cart($cart_id);
     if ($variation_id > 0) {
         $product_data = new WC_Product_Variation($variation_id);
     } else {
         $product_data = new WC_Product($product_id);
     }
     // Type/Exists check
     if ($product_data->is_type('external') || !$product_data->exists()) {
         $woocommerce->add_error(__('This product cannot be purchased.', 'woocommerce'));
         return false;
     }
     // Price set check
     if ($product_data->get_price() === '') {
         $woocommerce->add_error(__('This product cannot be purchased - the price is not yet set.', 'woocommerce'));
         return false;
     }
     // Stock check - only check if we're managing stock and backorders are not allowed
     if (!$product_data->has_enough_stock($quantity)) {
         $woocommerce->add_error(sprintf(__('You cannot add that amount to the cart since there is not enough stock. We have %s in stock.', 'woocommerce'), $product_data->get_stock_quantity()));
         return false;
     } elseif (!$product_data->is_in_stock()) {
         $woocommerce->add_error(__('You cannot add that product to the cart since the product is out of stock.', 'woocommerce'));
         return false;
     }
     if ($cart_item_key) {
         $quantity = $quantity + $this->cart_contents[$cart_item_key]['quantity'];
         // Stock check - this time accounting for whats already in-cart
         if (!$product_data->has_enough_stock($quantity)) {
             $woocommerce->add_error(sprintf(__('You cannot add that amount to the cart since there is not enough stock. We have %s in stock and you already have %s in your cart.', 'woocommerce'), $product_data->get_stock_quantity(), $this->cart_contents[$cart_item_key]['quantity']));
             return false;
         } elseif (!$product_data->is_in_stock()) {
             $woocommerce->add_error(__('You cannot add that product to the cart since the product is out of stock.', 'woocommerce'));
             return false;
         }
         $this->set_quantity($cart_item_key, $quantity);
     } else {
         // Add item after merging with $cart_item_data - hook to allow plugins to modify cart item
         $this->cart_contents[$cart_id] = apply_filters('woocommerce_add_cart_item', array_merge($cart_item_data, array('product_id' => $product_id, 'variation_id' => $variation_id, 'variation' => $variation, 'quantity' => $quantity, 'data' => $product_data)));
     }
     $this->set_session();
     return true;
 }
function pricemania_xml_feed_aktualizace()
{
    $args = array('nopaging' => true, 'post_type' => 'product', 'post_status' => 'publish', 'meta_key' => '_visibility', 'meta_value' => 'hidden', 'meta_compare' => '!=', 'fields' => 'ids');
    $products = get_posts($args);
    $global_dodaci_doba = get_option('wc_ceske_sluzby_xml_feed_heureka_dodaci_doba');
    $podpora_ean = get_option('wc_ceske_sluzby_xml_feed_heureka_podpora_ean');
    $postovne = get_option('wc_ceske_sluzby_xml_feed_pricemania_postovne');
    $xmlWriter = new XMLWriter();
    $xmlWriter->openMemory();
    $xmlWriter->setIndent(true);
    $xmlWriter->startDocument('1.0', 'utf-8');
    $xmlWriter->startElement('products');
    $i = 0;
    unlink(WP_CONTENT_DIR . '/pricemania.xml');
    foreach ($products as $product_id) {
        $ean = "";
        $dodaci_doba = "";
        $description = "";
        $skladem = false;
        $strom_kategorie = "";
        $i = $i + 1;
        $produkt = new WC_Product($product_id);
        $sku = $produkt->get_sku();
        if (!empty($podpora_ean) && $podpora_ean == "SKU") {
            $ean = $sku;
        }
        $skladem = $produkt->is_in_stock();
        if ($skladem && isset($global_dodaci_doba)) {
            $dodaci_doba = $global_dodaci_doba;
        }
        if (!empty($produkt->post->post_excerpt)) {
            $description = $produkt->post->post_excerpt;
        } else {
            $description = $produkt->post->post_content;
        }
        $kategorie = get_the_terms($product_id, 'product_cat');
        if ($kategorie && !is_wp_error($kategorie)) {
            $rodice_kategorie = get_ancestors($kategorie[0]->term_id, 'product_cat');
            if (!empty($rodice_kategorie)) {
                foreach ($rodice_kategorie as $rodic) {
                    $nazev_kategorie = get_term_by('ID', $rodic, 'product_cat');
                    $strom_kategorie = $nazev_kategorie->name . ' > ' . $strom_kategorie;
                }
            }
            $strom_kategorie .= $kategorie[0]->name;
        }
        $xmlWriter->startElement('product');
        $xmlWriter->writeElement('id', $product_id);
        $xmlWriter->startElement('name');
        $xmlWriter->text(wp_strip_all_tags($produkt->post->post_title));
        $xmlWriter->endElement();
        if (!empty($description)) {
            $xmlWriter->startElement('description');
            $xmlWriter->text(wp_strip_all_tags($description));
            $xmlWriter->endElement();
        }
        if (!empty($strom_kategorie)) {
            $xmlWriter->startElement('category');
            $xmlWriter->text($strom_kategorie);
            $xmlWriter->endElement();
        }
        $xmlWriter->writeElement('manufacturer', '');
        // https://wordpress.org/plugins/woocommerce-brand/
        $xmlWriter->writeElement('url', get_permalink($product_id));
        $xmlWriter->writeElement('picture', wp_get_attachment_url(get_post_thumbnail_id($product_id)));
        if ($dodaci_doba != "") {
            $xmlWriter->writeElement('availability', $dodaci_doba);
        }
        if ($postovne != "") {
            $xmlWriter->writeElement('shipping', $postovne);
        }
        $xmlWriter->writeElement('price', $produkt->price);
        if (!empty($ean)) {
            $xmlWriter->writeElement('ean', $ean);
        }
        $xmlWriter->endElement();
        if (0 == $i % 1000) {
            file_put_contents(WP_CONTENT_DIR . '/pricemania.xml', $xmlWriter->flush(true), FILE_APPEND);
        }
    }
    $xmlWriter->endElement();
    $xmlWriter->endDocument();
    header('Content-type: text/xml');
    file_put_contents(WP_CONTENT_DIR . '/pricemania.xml', $xmlWriter->flush(true), FILE_APPEND);
}
示例#19
0
/**
 * @param $atts
 */
function alfw_slider_render_func($atts)
{
    global $wpdb, $lookbook_slider_effects;
    if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
        do_action('check_woocommerce');
        return;
    }
    $upload_dir_info = wp_upload_dir();
    $wp_root_path = get_home_path();
    $site_url = get_site_url();
    $plugin_folder_name = pathinfo(ALTIMA_LOOKBOOK_PLUGIN_DIR);
    wp_enqueue_script('hotspots');
    wp_enqueue_script('actual');
    wp_enqueue_script('carousel');
    wp_enqueue_script('flip');
    wp_enqueue_script('scrolV');
    wp_enqueue_script('shuffle');
    wp_enqueue_script('tile');
    wp_enqueue_script('additionalEffect');
    wp_enqueue_script('swipe');
    //$wpdb->show_errors();
    extract($atts);
    /**
     * Get slider options
     */
    $show_desc = get_option("wplb_free_show_desc_in_popup");
    $show_addcart = get_option("wplb_free_show_addcart_in_popup");
    $path_2_pic = get_option('wplb_free_hspt_icon', $site_url . '/wp-content/plugins/' . $plugin_folder_name['basename'] . '/admin/images/hotspot-icon.png');
    if (empty($path_2_pic)) {
        $path_2_pic = $site_url . '/wp-content/plugins/' . $plugin_folder_name['basename'] . '/admin/images/hotspot-icon.png';
    }
    $hot_point_icon = '<img class="hotspot-icon" src="' . $path_2_pic . '" />';
    $only_visible_element = 'AND `status`=1';
    if (@$admin) {
        $only_visible_element = '';
    }
    $slider = $wpdb->get_results($wpdb->prepare("SELECT\n                slider.*\n            FROM\n                `" . $wpdb->prefix . SLIDER_TABLE . "` AS slider\n            WHERE\n                    `slider`.`id` = %d {$only_visible_element}", $slider_id), ARRAY_A);
    if (!empty($slider)) {
        $slides = $wpdb->get_results($wpdb->prepare("SELECT\n                    slide.*\n                FROM\n                    `" . $wpdb->prefix . SLIDES_TABLE . "` AS slide\n                WHERE\n                    slider_id = %d {$only_visible_element}\n                ORDER BY\n                    order_flag", $slider[0]['id']), ARRAY_A);
    }
    if (empty($slides)) {
        echo __('No slides available in this slider!');
    } else {
        $effects = unserialize($slider[0]['slider_effect']);
        $slider_count = count($slides);
        //var_dump(json_decode($slides[0]['hotsposts']));
        alfw_control_js($slider[0]['id']);
        /**
         * Work with sliders effect
         */
        if (!empty($effects)) {
            $effects_string = '';
            if (in_array('all', $effects)) {
                unset($lookbook_slider_effects['all']);
                unset($lookbook_slider_effects['none']);
                $fx_names = array_keys($lookbook_slider_effects);
                $fx_count = count($fx_names);
                $sl_count = $slider_count;
                for ($i = 0; $i < $sl_count; $i++) {
                    $slides[$i]['fx'] = 'data-cycle-fx="' . $fx_names[rand(2, $fx_count)] . '"';
                }
            } elseif (in_array('none', $effects)) {
                $effects_string = 'data-cycle-fx="none"';
            } else {
                $fx_count = count($effects) - 1;
                $sl_count = $slider_count;
                for ($i = 0; $i < $sl_count; $i++) {
                    $slides[$i]['fx'] = 'data-cycle-fx="' . $effects[rand(0, $fx_count)] . '"';
                }
            }
        }
        echo '<div class="lb_conteyner">';
        /**
         * Output content before
         */
        if (!empty($slider[0]['content_before'])) {
            echo '<div class="c_before">' . $slider[0]['content_before'] . '</div>';
        }
        /**
         * Showing the caption
         */
        $caption_plugin = '';
        if ($slider[0]['show_slide_caption']) {
            $caption_plugin = 'data-cycle-caption-plugin="caption2"';
        }
        /**
         * Adding thumbneil pager
         */
        $thumb = '';
        $simple_pager = '';
        if ($slider[0]['show_thumbnails']) {
            $thumb = 'data-cycle-pager="#no-template-pager"
            data-cycle-pager-template=""';
        } else {
            $simple_pager = '
                data-cycle-pager="#pagernav_' . $slider[0]['id'] . ' .cycle"
                data-cycle-pager-template="<li><span> {{slideNum}} </span></li>"';
        }
        /**
         * Output the slider
         * cycle-slideshow
         */
        echo '<div
            id="lookbookslider_' . $slider[0]['id'] . '"
            class="cycle-slideshow"
            data-cycle-speed="' . $slider[0]['transition_duration'] . '"
            data-cycle-timeout="' . $slider[0]['pause'] . '"
            data-cycle-slides="> div.slide"
            ' . $effects_string . '
            ' . $caption_plugin . '
            ' . $thumb . '
            ' . $simple_pager . '
            data-cycle-next="> .slide-next"
            data-cycle-prev="> .slide-prev"
            data-cycle-log="false"
            data-cycle-auto-height="container"
            data-cycle-swipe=true
            data-cycle-swipe-fx=scrollHorz
            >';
        /**
         * Showing the caption
         */
        if ($slider_count > 1) {
            if ($slider[0]['show_slide_caption']) {
                echo '<div class="cycle-caption"></div>';
                //echo '<div class="cycle-overlay"></div>';
            }
        }
        /**
         * Showing nawigation buttons
         */
        if ($slider[0]['show_navigation'] && $slider_count > 1) {
            $hover = '';
            if ($slider[0]['navigation_on_hover_state_only']) {
                $hover = 'hover';
            }
            echo '
            <div class="slide_commands ' . $hover . '">
                <div class="slide_play" style="display: none;"></div>
                <div class="slide_stop" style="display: block;"></div>
            </div>';
            echo '<div class="slide-prev ' . $hover . '"><span></span></div>';
            echo '<div class="slide-next ' . $hover . '"><span></span></div>';
        }
        foreach ($slides as &$slide) {
            /**
             * Add to hotspot product information
             */
            $hotspots = json_decode($slide['hotsposts']);
            if (!empty($hotspots)) {
                foreach ($hotspots as &$point) {
                    /**
                     * $point->sku - it's post id not product sku
                     */
                    if (!empty($point->sku) && is_numeric($point->sku)) {
                        $post_data = get_post($point->sku, ARRAY_A);
                        $product = new WC_Product($post_data['ID']);
                        $price = $product->get_price_html();
                        $stock_status = $product->is_in_stock() ? 'In stock' : 'Out of stock';
                        $product_url = get_permalink($post_data['ID']);
                        $url = wp_get_attachment_image_src(get_post_thumbnail_id($post_data['ID']));
                        $status_block = '';
                        $price_block = '';
                        $text_block = '';
                        $addcart_block = '';
                        $img_block = '';
                        if ($show_desc) {
                            $img_block = !empty($url[0]) ? '<img src="' . $url[0] . '" style="width:50px" />' : '';
                        }
                        switch ($post_data['post_type']) {
                            case 'post':
                                if ($show_desc) {
                                    $text_block = mb_substr(strip_tags($post_data['post_content']), 0, 100);
                                }
                                break;
                            case 'page':
                                if ($show_desc) {
                                    $text_block = mb_substr(strip_tags($post_data['post_content']), 0, 100);
                                }
                                break;
                            case 'product':
                                $status_block = '<div class="out-of-stock"><span>' . $stock_status . '</span></div>';
                                $price_block = '<div class="price">' . $price . '</div>';
                                if ($show_desc) {
                                    $text_block = mb_substr(strip_tags($post_data['post_excerpt']), 0, 100);
                                }
                                if ($show_addcart) {
                                    $addcart_block = '<div class="add-to-cart">
                                            <form method="post" action="' . esc_url($product_url) . '">
                                                <input type="hidden" value="' . $post_data['ID'] . '" name="add-to-cart">
                                                <label for="qty">' . __('Qty') . ':</label>
                                                <input type="text" class="qty" title="Qty" value="1" maxlength="12" id="qty" name="quantity">
                                                <button class="button btn-cart" title="Add to Cart" type="submit"><span>' . __('Add to Cart') . '</span></button>
                                            </form>
                                        </div>';
                                }
                                break;
                        }
                        $point->text = '<div class="product-info">
                                <div class="pro-detail-div">
                                    <div class="left-detail">
                                        <a href="' . $product_url . '">' . $post_data['post_title'] . '</a>
                                        ' . $status_block . '
                                        <div class="desc">
                                            ' . $img_block . '
                                            ' . $text_block . '
                                        </div>
                                        ' . $price_block . '
                                        ' . $addcart_block . '
                                    </div>
                                </div>
                            </div>' . $hot_point_icon;
                    } else {
                        $point->text = '<div class="product-info">
                                                <div class="pro-detail-div">
                                                    <div>
                                                        <a href="' . $point->href . '" target="_blank">' . $point->text . '</a>
                                                    </div>
                                                </div>
                                            </div>' . $hot_point_icon;
                    }
                }
                $slide['hotsposts'] = json_encode($hotspots);
            }
            /**
             * Output slides
             */
            $a_start = $a_end = '';
            if (!empty($slide['link'])) {
                $a_start = '<a href="' . $slide['link'] . '">';
                $a_end = '</a>';
            }
            $overley = '';
            if ($slider_count > 1) {
                if ($slider[0]['show_slide_caption']) {
                    $overley = '<div class="cycle-overlay">' . $slide['caption'] . '&nbsp;</div>';
                }
            }
            echo '<div class="slide" id="s_img_' . $slide['id'] . '" ' . $slide['fx'] . ' data-cycle-desc="' . $slide['caption'] . '">
                    ' . $a_start . '<img src="' . $upload_dir_info['baseurl'] . '/' . UPLOAD_FOLDER_NAME . '/' . $slider_id . '/' . $slide['picture'] . '" alt="' . $slide['caption'] . '" />' . $overley . $a_end . '
                 </div>' . "\n";
        }
        echo '<div id="progress_' . $slider[0]['id'] . '"></div>';
        unset($slide);
        echo '</div>';
        alfw_add_hotspots($slides, $slider[0]['id']);
        /**
         * Showing thumbneils pages
         */
        if ($slider_count > 1) {
            if ($slider[0]['show_thumbnails']) {
                alfw_thumbnails_js($slider[0]['id']);
                echo '<div id="pagernav_' . $slider[0]['id'] . '" class="pagernav" style="max-width: ' . $slider[0]['width'] . 'px;">
                    <ul id="thumb_nav" class="cycle-slideshow"
                        data-cycle-slides="> li.thumb"
                        data-cycle-timeout="0"
                        data-cycle-fx="carousel"
                        data-cycle-carousel-visible="' . $slider_count . '"
                        data-cycle-carousel-fluid=true
                        data-allow-wrap="false"
                        data-cycle-log="false"
                        data-cycle-prev="#pagernav_' . $slider[0]['id'] . ' .cycle-prev"
                        data-cycle-next="#pagernav_' . $slider[0]['id'] . ' .cycle-next"
                    >';
                foreach ($slides as $slide) {
                    echo '<li class="thumb">
                                <img src="' . $upload_dir_info['baseurl'] . '/' . UPLOAD_FOLDER_NAME_THUMB . '/' . $slider_id . '/' . $slide['picture'] . '" alt="' . $slide['caption'] . '" />
                             </li>' . "\n";
                }
                echo '</ul>
                </div>';
            } else {
                /**
                 * Simple pager
                 */
                echo '
                <div class="pagernav" id="pagernav_' . $slider[0]['id'] . '">
                    <ul class="cycle">
                    </ul>
                </div>';
            }
        }
        /**
         * Output content after
         */
        if (!empty($slider[0]['content_after'])) {
            echo '<div class="c_after">' . $slider[0]['content_after'] . '</div>';
        }
        echo '</div>';
    }
}
function WooComposer_Single_style03($atts)
{
    $product_id = $product_style = $display_elements = $img_animate = $text_align = $color_heading = $color_categories = $color_price = '';
    $color_rating = $color_rating_bg = $color_quick_bg = $color_quick = $color_cart_bg = $color_cart = $color_product_desc = '';
    $color_product_desc_bg = $size_title = $size_cat = $size_price = $color_on_sale = $color_on_sale_bg = $label_on_sale = $border_style = '';
    $border_color = $border_size = $border_radius = $sale_price = $on_sale_alignment = $on_sale_style = $product_img_disp = '';
    extract(shortcode_atts(array("product_id" => "", "product_style" => "style01", "display_elements" => "", "label_on_sale" => "Sale!", "text_align" => "left", "img_animate" => "rotate-clock", "color_heading" => "", "color_categories" => "", "color_price" => "", "color_rating" => "", "color_rating_bg" => "", "color_quick_bg" => "", "color_quick" => "", "color_cart_bg" => "", "color_on_sale_bg" => "", "color_on_sale" => "", "color_cart" => "", "color_product_desc" => "", "color_product_desc_bg" => "", "size_title" => "", "size_cat" => "", "size_price" => "", "border_style" => "", "border_color" => "", "border_size" => "", "border_radius" => "", "sale_price" => "", "on_sale_style" => "wcmp-sale-circle", "on_sale_alignment" => "wcmp-sale-right", "product_img_disp" => "single"), $atts));
    $output = $heading_style = $cat_style = $price_style = $cart_style = $cart_bg_style = $view_style = $view_bg_style = $rating_style = '';
    $desc_style = $label_style = $border = $desc_style = $sale_price_size = '';
    $image_size = apply_filters('single_product_large_thumbnail_size', 'shop_single');
    if ($sale_price !== '') {
        $sale_price_size = 'font-size:' . $sale_price . 'px;';
    }
    $img_animate = 'wcmp-img-' . $img_animate;
    if ($border_style !== '') {
        $border .= 'border:' . $border_size . 'px ' . $border_style . ' ' . $border_color . ';';
        $border .= 'border-radius:' . $border_radius . 'px;';
    }
    if ($color_product_desc_bg !== '') {
        $desc_style .= 'background:' . $color_product_desc_bg . ';';
    }
    if ($color_product_desc !== '') {
        $desc_style .= 'color:' . $color_product_desc . ';';
    }
    if ($color_heading !== "") {
        $heading_style = 'color:' . $color_heading . ';';
    }
    if ($size_title !== "") {
        $heading_style .= 'font-size:' . $size_title . 'px;';
    }
    if ($color_categories !== "") {
        $cat_style = 'color:' . $color_categories . ';';
    }
    if ($size_cat !== "") {
        $cat_style .= 'font-size:' . $size_cat . 'px;';
    }
    if ($color_price !== "") {
        $price_style = 'color:' . $color_price . ';';
    }
    if ($size_price !== "") {
        $price_style .= 'font-size:' . $size_price . 'px;';
    }
    if ($color_rating !== "") {
        $rating_style .= 'color:' . $color_rating . ';';
    }
    if ($color_rating_bg !== "") {
        $rating_style .= 'background:' . $color_rating_bg . ';';
    }
    if ($color_quick_bg !== "") {
        $view_bg_style = 'background:' . $color_quick_bg . ';';
    }
    if ($color_quick !== "") {
        $view_style = 'color:' . $color_quick . ';';
    }
    if ($color_cart_bg !== "") {
        $cart_bg_style = 'background:' . $color_cart_bg . ';';
    }
    if ($color_cart !== "") {
        $cart_style = 'color:' . $color_cart . ';';
    }
    if ($color_on_sale_bg !== "") {
        $label_style = 'background:' . $color_on_sale_bg . ';';
    }
    if ($color_on_sale !== "") {
        $label_style .= 'color:' . $color_on_sale . ';';
    }
    $elemets = explode(",", $display_elements);
    $product_title = get_the_title($product_id);
    $post = get_post($product_id);
    $product_desc = get_post($product_id)->post_excerpt;
    $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
    $product = new WC_Product($product_id);
    $attachment_ids = $product->get_gallery_attachment_ids();
    $price = $product->get_price_html();
    $rating = $product->get_rating_html();
    $attributes = $product->get_attributes();
    $stock = $product->is_in_stock() ? 'InStock' : 'OutOfStock';
    if ($product->is_on_sale()) {
        $on_sale = apply_filters('woocommerce_sale_flash', $label_on_sale, $post, $product);
    } else {
        $on_sale = '';
    }
    $cat_count = sizeof(get_the_terms($product_id, 'product_cat'));
    $tag_count = sizeof(get_the_terms($product_id, 'product_tag'));
    $categories = $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>');
    $tags = $product->get_tags(', ', '<span class="tagged_as">' . _n('', '', $tag_count, 'woocommerce') . ' ', '.</span>');
    $output .= "\n" . '<div class="wcmp-product woocommerce wcmp-' . $product_style . ' ' . $img_animate . '" style="' . $border . ' ' . $desc_style . '">';
    $output .= "\n\t" . '<div class="wcmp-product-image">';
    if (!empty($attachment_ids) && count($attachment_ids) > 1 && $product_img_disp == "carousel") {
        $uniqid = uniqid();
        $output .= '<div class="wcmp-single-image-carousel">';
        $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
        $src = $product_img[0];
        $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>';
        foreach ($attachment_ids as $attachment_id) {
            $product_img = wp_get_attachment_image_src($attachment_id, $image_size);
            $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>';
        }
        $output .= '</div>';
    } else {
        $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
        $src = $product_img[0];
        $output .= '<a href="' . get_permalink($product_id) . '"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></a>';
    }
    if ($on_sale !== '') {
        $output .= "\n" . '<div class="wcmp-onsale ' . $on_sale_alignment . ' ' . $on_sale_style . '"><span class="onsale" style="' . $label_style . ' ' . $sale_price_size . '">' . $on_sale . '</span></div>';
    }
    if ($stock == 'OutOfStock') {
        $output .= "\n" . '<span class="wcmp-out-stock">' . __('Out Of Stock!', 'woocomposer') . '</span>';
    }
    $output .= '</div>';
    $output .= "\n\t" . '<div class="wcmp-product-desc">';
    $output .= '<a href="' . get_permalink($product_id) . '">';
    $output .= "\n\t\t" . '<h2 style="' . $heading_style . '">' . $product_title . '</h2>';
    $output .= '</a>';
    if (in_array("category", $elemets)) {
        $output .= '<h5 style="' . $cat_style . '">';
        if ($categories !== '') {
            $output .= $categories;
            $output .= $tags;
        }
        $output .= '</h5>';
    }
    $output .= "\n\t\t" . '<div class="wcmp-price"><span class="price" style="' . $price_style . '">' . $price . '</span></div>';
    $output .= '<div class="wcmp-style3-cart-block">';
    /*Class Start wcmp-style3-cart-block*/
    $output .= '<div class="wcmp-add-to-cart" style="' . $cart_bg_style . '"><a style="' . $cart_style . '" title="Add to Cart" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-product_id="' . $product_id . '" data-product_sku="" class="button add_to_cart_button product_type_simple">Add to Cart</a></div>';
    if (in_array("reviews", $elemets)) {
        $output .= "\n" . '<div class="wcmp-star-ratings" style="' . $rating_style . '">' . $rating . '</div>';
    }
    if (in_array("quick", $elemets)) {
        $output .= '<div class="wcmp-quick-view quick-view-single" style="' . $view_bg_style . '"><a style="' . $view_style . '" title="Quick View" href="' . get_permalink($product_id) . '"><i class="wooicon-plus32"></i></a></div>';
    }
    $output .= '</div>';
    /*Class End wcmp-style3-cart-block*/
    if (in_array("description", $elemets)) {
        $output .= "\n\t\t" . '<div class="wcmp-product-content" style="' . $desc_style . '">' . $product_desc . '</div>';
    }
    if (in_array("quick", $elemets)) {
        $query = new WP_Query(array('post_type' => 'product', 'post__in' => array($product_id)));
        if ($query->have_posts()) {
            while ($query->have_posts()) {
                $query->the_post();
                $output .= '<div class="wcmp-quick-view-wrapper">';
                $output .= '<div class="wcmp-quick-view-wrapper woocommerce">';
                $output .= '<div class="wcmp-close-single"><i class="wooicon-cross2"></i></div>';
                if (!empty($attachment_ids) && count($attachment_ids) > 1) {
                    $uniqid = uniqid();
                    $output .= '<div class="wcmp-image-carousel wcmp-carousel-' . $uniqid . '" data-class="wcmp-carousel-' . $uniqid . '">';
                    foreach ($attachment_ids as $attachment_id) {
                        $product_img = wp_get_attachment_image_src($attachment_id, $image_size);
                        $output .= '<div><div class="wcmp-image"><img src="' . $product_img[0] . '"/></div></div>';
                    }
                    $output .= '</div>';
                } else {
                    $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
                    $output .= '<div class="wcmp-single-image"><img src="' . $product_img[0] . '"/></div>';
                }
                $output .= '<div class="wcmp-product-content-single">';
                ob_start();
                do_action('woocommerce_single_product_summary');
                $output .= ob_get_clean();
                $output .= '</div>';
                $output .= '<div class="clear"></div>';
                $output .= '</div>';
                $output .= '</div>';
            }
        }
    }
    $output .= "\n\t" . '</div>';
    $output .= "\n\t" . '</div>';
    return $output;
}
示例#21
0
function woocommerce_custom_product_columns($column)
{
    global $post, $woocommerce;
    $product = new WC_Product($post->ID);
    switch ($column) {
        case "thumb":
            $product->get_image();
            break;
        case "name":
            $edit_link = get_edit_post_link($post->ID);
            $title = _draft_or_post_title();
            $post_type_object = get_post_type_object($post->post_type);
            $can_edit_post = current_user_can($post_type_object->cap->edit_post, $post->ID);
            echo '<strong><a class="row-title" href="' . $edit_link . '">' . $title . '</a>';
            _post_states($post);
            echo '</strong>';
            if ($post->post_parent > 0) {
                echo '&nbsp;&nbsp;&larr; <a href="' . get_edit_post_link($post->post_parent) . '">' . get_the_title($post->post_parent) . '</a>';
            }
            // Excerpt view
            if (isset($_GET['mode']) && $_GET['mode'] == 'excerpt') {
                echo apply_filters('the_excerpt', $post->post_excerpt);
            }
            // Get actions
            $actions = array();
            $actions['id'] = 'ID: ' . $post->ID;
            if ($can_edit_post && 'trash' != $post->post_status) {
                $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this item inline', 'woocommerce')) . '">' . __('Quick&nbsp;Edit', 'woocommerce') . '</a>';
            }
            if (current_user_can($post_type_object->cap->delete_post, $post->ID)) {
                if ('trash' == $post->post_status) {
                    $actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash', 'woocommerce')) . "' href='" . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $post->ID)), 'untrash-' . $post->post_type . '_' . $post->ID) . "'>" . __('Restore', 'woocommerce') . "</a>";
                } elseif (EMPTY_TRASH_DAYS) {
                    $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash', 'woocommerce')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash', 'woocommerce') . "</a>";
                }
                if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) {
                    $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently', 'woocommerce')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently', 'woocommerce') . "</a>";
                }
            }
            if ($post_type_object->public) {
                if (in_array($post->post_status, array('pending', 'draft'))) {
                    if ($can_edit_post) {
                        $actions['view'] = '<a href="' . esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;', 'woocommerce'), $title)) . '" rel="permalink">' . __('Preview', 'woocommerce') . '</a>';
                    }
                } elseif ('trash' != $post->post_status) {
                    $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;', 'woocommerce'), $title)) . '" rel="permalink">' . __('View', 'woocommerce') . '</a>';
                }
            }
            $actions = apply_filters('post_row_actions', $actions, $post);
            echo '<div class="row-actions">';
            $i = 0;
            $action_count = sizeof($actions);
            foreach ($actions as $action => $link) {
                ++$i;
                $i == $action_count ? $sep = '' : ($sep = ' | ');
                echo "<span class='{$action}'>{$link}{$sep}</span>";
            }
            echo '</div>';
            get_inline_data($post);
            /* Custom inline data for woocommerce */
            echo '
				<div class="hidden" id="woocommerce_inline_' . $post->ID . '">
					<div class="sku">' . $product->sku . '</div>
					<div class="regular_price">' . $product->regular_price . '</div>
					<div class="sale_price">' . $product->sale_price . '</div>
					<div class="weight">' . $product->weight . '</div>
					<div class="length">' . $product->length . '</div>
					<div class="width">' . $product->width . '</div>
					<div class="height">' . $product->height . '</div>
					<div class="visibility">' . $product->visibility . '</div>
					<div class="stock_status">' . $product->stock_status . '</div>
					<div class="stock">' . $product->stock . '</div>
					<div class="manage_stock">' . $product->manage_stock . '</div>
					<div class="featured">' . $product->featured . '</div>
					<div class="product_type">' . $product->product_type . '</div>
					<div class="product_is_virtual">' . $product->virtual . '</div>
				</div>
			';
            break;
        case "sku":
            if ($product->get_sku()) {
                echo $product->get_sku();
            } else {
                echo '<span class="na">&ndash;</span>';
            }
            break;
        case "product_type":
            if ($product->product_type == 'grouped') {
                echo '<span class="product-type tips ' . $product->product_type . '" tip="' . __('Grouped', 'woocommerce') . '"></span>';
            } elseif ($product->product_type == 'external') {
                echo '<span class="product-type tips ' . $product->product_type . '" tip="' . __('External/Affiliate', 'woocommerce') . '"></span>';
            } elseif ($product->product_type == 'simple') {
                if ($product->is_virtual()) {
                    echo '<span class="product-type tips virtual" tip="' . __('Virtual', 'woocommerce') . '"></span>';
                } elseif ($product->is_downloadable()) {
                    echo '<span class="product-type tips downloadable" tip="' . __('Downloadable', 'woocommerce') . '"></span>';
                } else {
                    echo '<span class="product-type tips ' . $product->product_type . '" tip="' . __('Simple', 'woocommerce') . '"></span>';
                }
            } elseif ($product->product_type == 'variable') {
                echo '<span class="product-type tips ' . $product->product_type . '" tip="' . __('Variable', 'woocommerce') . '"></span>';
            } else {
                // Assuming that we have other types in future
                echo '<span class="product-type tips ' . $product->product_type . '" tip="' . ucwords($product->product_type) . '"></span>';
            }
            break;
        case "price":
            if ($product->get_price_html()) {
                echo $product->get_price_html();
            } else {
                echo '<span class="na">&ndash;</span>';
            }
            break;
        case "product_cat":
            if (!($terms = get_the_term_list($post->ID, 'product_cat', '', ', ', ''))) {
                echo '<span class="na">&ndash;</span>';
            } else {
                echo $terms;
            }
            break;
        case "product_tags":
            if (!($terms = get_the_term_list($post->ID, 'product_tag', '', ', ', ''))) {
                echo '<span class="na">&ndash;</span>';
            } else {
                echo $terms;
            }
            break;
        case "featured":
            $url = wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce-feature-product&product_id=' . $post->ID), 'woocommerce-feature-product');
            echo '<a href="' . $url . '" title="' . __('Change', 'woocommerce') . '">';
            if ($product->is_featured()) {
                echo '<a href="' . $url . '"><img src="' . $woocommerce->plugin_url() . '/assets/images/featured.png" alt="yes" />';
            } else {
                echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/featured-off.png" alt="no" />';
            }
            echo '</a>';
            break;
        case "is_in_stock":
            if ($product->is_in_stock()) {
                echo '<mark class="instock">' . __('In stock', 'woocommerce') . '</mark>';
            } else {
                echo '<mark class="outofstock">' . __('Out of stock', 'woocommerce') . '</mark>';
            }
            if ($product->managing_stock()) {
                echo ' &times; ' . $product->get_total_stock();
            }
            break;
    }
}
 /**
  * Check stock before attempting to call the add_to_cart function
  * Some double checking happens, but it's better than partially adding items to the cart
  **/
 function validate_stock($product_id, $variation_id, $quantity, $exclude_cart, $silent)
 {
     global $woocommerce;
     if ($variation_id > 0) {
         if ($this->is_wc_v2()) {
             $product_data = get_product($variation_id, array('product_type' => 'variation'));
         } else {
             $product_data = new WC_Product_Variation($variation_id);
         }
     } else {
         if ($this->is_wc_v2()) {
             $product_data = get_product($product_id, array('product_type' => 'simple'));
         } else {
             $product_data = new WC_Product($product_id);
         }
     }
     // Stock check - only check if we're managing stock and backorders are not allowed.
     if (!$product_data->is_in_stock()) {
         if (!$silent) {
             $woocommerce->add_error(sprintf(__('You cannot add this product to the cart since "%s" is out of stock.', 'woo-bundles'), $product_data->get_title()));
         }
         return false;
     } elseif (!$product_data->has_enough_stock($quantity)) {
         if (!$silent) {
             $woocommerce->add_error(sprintf(__('You cannot add that amount to the cart since there is not enough stock of "%s". We have %s in stock.', 'woo-bundles'), $product_data->get_title(), $product_data->get_stock_quantity()));
         }
         return false;
     }
     // Stock check - this time accounting for whats already in-cart.
     if ($exclude_cart) {
         return true;
     }
     $product_qty_in_cart = $woocommerce->cart->get_cart_item_quantities();
     if ($product_data->managing_stock()) {
         // Variations
         if ($variation_id && $product_data->variation_has_stock) {
             if (isset($product_qty_in_cart[$variation_id]) && !$product_data->has_enough_stock($product_qty_in_cart[$variation_id] + $quantity)) {
                 if (!$silent) {
                     $woocommerce->add_error(sprintf(__('<a href="%s" class="button">%s</a>You cannot add that amount to the cart since there is not enough stock of "%s" &mdash; we have %s in stock and you already have %s in your cart.', 'woo-bundles'), get_permalink(woocommerce_get_page_id('cart')), __('View Cart &rarr;', 'woocommerce'), $product_data->get_title(), $product_data->get_stock_quantity(), $product_qty_in_cart[$variation_id]));
                 }
                 return false;
             }
             // Products
         } else {
             if (isset($product_qty_in_cart[$product_id]) && !$product_data->has_enough_stock($product_qty_in_cart[$product_id] + $quantity)) {
                 if (!$silent) {
                     $woocommerce->add_error(sprintf(__('<a href="%s" class="button">%s</a>You cannot add that amount to the cart since there is not enough stock of "%s" &mdash; we have %s in stock and you already have %s in your cart.', 'woo-bundles'), get_permalink(woocommerce_get_page_id('cart')), __('View Cart &rarr;', 'woocommerce'), $product_data->get_title(), $product_data->get_stock_quantity(), $product_qty_in_cart[$product_id]));
                 }
                 return false;
             }
         }
     }
     return true;
 }
示例#23
0
        $params = array('width' => 120, 'height' => 90);
        echo bfi_thumb($term_brand_image['brand_image'], $params);
        ?>
" alt="<?php 
        the_title_attribute();
        ?>
" />               
                </div>
                <?php 
    }
    ?>
            </div>                     
            <div class="buttons_col">
                <div class="priced_block">
                    <?php 
    if ($product->is_in_stock() && $product->add_to_cart_url() != '') {
        ?>
                        <?php 
        echo apply_filters('woocommerce_loop_add_to_cart_link', sprintf('<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="btn_offer_block %s product_type_%s"%s>%s</a>', esc_url($product->add_to_cart_url()), esc_attr($product->id), esc_attr($product->get_sku()), $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : 'add_to_cart_button', esc_attr($product->product_type), $product->product_type == 'external' ? ' target="_blank"' : '', esc_html($product->add_to_cart_text())), $product);
        ?>
                    <?php 
    }
    ?>
                </div>
                <?php 
    $offer_coupon = get_post_meta(get_the_ID(), 'rehub_woo_coupon_code', true);
    ?>
                <?php 
    $offer_coupon_date = get_post_meta(get_the_ID(), 'rehub_woo_coupon_date', true);
    ?>
                <?php 
示例#24
0
 private function get_product_from_post($post_id)
 {
     $woocommerce_ver_below_2_1 = false;
     if (version_compare(WOOCOMMERCE_VERSION, '2.1', '<')) {
         $woocommerce_ver_below_2_1 = true;
     }
     if ($woocommerce_ver_below_2_1) {
         $product = new WC_Product_Simple($post_id);
     } else {
         $product = new WC_Product($post_id);
     }
     //$post_categories = wp_get_post_categories( $post_id );
     //$categories = get_the_category();
     try {
         $thumbnail = $product->get_image();
         if ($thumbnail) {
             if (preg_match('/data-lazy-src="([^\\"]+)"/s', $thumbnail, $match)) {
                 $thumbnail = $match[1];
             } else {
                 if (preg_match('/data-lazy-original="([^\\"]+)"/s', $thumbnail, $match)) {
                     $thumbnail = $match[1];
                 } else {
                     if (preg_match('/lazy-src="([^\\"]+)"/s', $thumbnail, $match)) {
                         // Animate Lazy Load Wordpress Plugin
                         $thumbnail = $match[1];
                     } else {
                         if (preg_match('/data-echo="([^\\"]+)"/s', $thumbnail, $match)) {
                             $thumbnail = $match[1];
                         } else {
                             preg_match('/<img(.*)src(.*)=(.*)"(.*)"/U', $thumbnail, $result);
                             $thumbnail = array_pop($result);
                         }
                     }
                 }
             }
         }
     } catch (Exception $e) {
         $err_msg = "exception raised in thumbnails";
         self::send_error_report($err_msg);
         $thumbnail = '';
     }
     // handling scheduled sale price update
     if (!$woocommerce_ver_below_2_1) {
         $sale_price_dates_from = get_post_meta($post_id, '_sale_price_dates_from', true);
         $sale_price_dates_to = get_post_meta($post_id, '_sale_price_dates_to', true);
         if ($sale_price_dates_from || $sale_price_dates_to) {
             self::schedule_sale_price_update($post_id, null);
         }
         if ($sale_price_dates_from) {
             self::schedule_sale_price_update($post_id, $sale_price_dates_from);
         }
         if ($sale_price_dates_to) {
             self::schedule_sale_price_update($post_id, $sale_price_dates_to);
         }
     }
     $product_tags = array();
     foreach (wp_get_post_terms($post_id, 'product_tag') as $tag) {
         $product_tags[] = $tag->name;
     }
     $product_brands = array();
     if (taxonomy_exists('product_brand')) {
         foreach (wp_get_post_terms($post_id, 'product_brand') as $brand) {
             $product_brands[] = $brand->name;
         }
     }
     $taxonomies = array();
     try {
         $all_taxonomies = get_option('wcis_taxonomies');
         if (is_array($all_taxonomies)) {
             foreach ($all_taxonomies as $taxonomy) {
                 if (taxonomy_exists($taxonomy) && !array_key_exists($taxonomy, $taxonomies)) {
                     foreach (wp_get_post_terms($post_id, $taxonomy) as $taxonomy_value) {
                         if (!array_key_exists($taxonomy, $taxonomies)) {
                             $taxonomies[$taxonomy] = array();
                         }
                         $taxonomies[$taxonomy][] = $taxonomy_value->name;
                     }
                 }
             }
         }
     } catch (Exception $e) {
     }
     $acf_fields = array();
     try {
         if (class_exists('acf') && function_exists('get_field')) {
             $all_acf_fields = get_option('wcis_acf_fields');
             if (is_array($all_acf_fields)) {
                 foreach ($all_acf_fields as $acf_field_name) {
                     $acf_field_value = get_field($acf_field_name, $post_id);
                     if ($acf_field_value) {
                         $acf_fields[$acf_field_name] = $acf_field_value;
                     }
                 }
             }
         }
     } catch (Exception $e) {
     }
     $send_product = array('product_id' => $product->id, 'currency' => get_woocommerce_currency(), 'price' => $product->get_price(), 'url' => get_permalink($product->id), 'thumbnail_url' => $thumbnail, 'action' => 'insert', 'description' => $product->get_post_data()->post_content, 'short_description' => $product->get_post_data()->post_excerpt, 'name' => $product->get_title(), 'sku' => $product->get_sku(), 'categories' => $product->get_categories(), 'tag' => $product_tags, 'store_id' => get_current_blog_id(), 'identifier' => (string) $product->id, 'product_brand' => $product_brands, 'taxonomies' => $taxonomies, 'acf_fields' => $acf_fields, 'sellable' => $product->is_purchasable(), 'visibility' => $product->is_visible(), 'stock_quantity' => $product->get_stock_quantity(), 'is_managing_stock' => $product->managing_stock(), 'is_backorders_allowed' => $product->backorders_allowed(), 'is_purchasable' => $product->is_purchasable(), 'is_in_stock' => $product->is_in_stock(), 'product_status' => get_post_status($post_id));
     try {
         $variable = new WC_Product_Variable($post_id);
         $variations = $variable->get_available_variations();
         $variations_sku = '';
         if (!empty($variations)) {
             foreach ($variations as $variation) {
                 if ($product->get_sku() != $variation['sku']) {
                     $variations_sku .= $variation['sku'] . ' ';
                 }
             }
         }
         $send_product['variations_sku'] = $variations_sku;
         $all_attributes = $product->get_attributes();
         $attributes = array();
         if (!empty($all_attributes)) {
             foreach ($all_attributes as $attr_mame => $value) {
                 if ($all_attributes[$attr_mame]['is_taxonomy']) {
                     if (!$woocommerce_ver_below_2_1) {
                         $attributes[$attr_mame] = wc_get_product_terms($post_id, $attr_mame, array('fields' => 'names'));
                     } else {
                         $attributes[$attr_mame] = woocommerce_get_product_terms($post_id, $attr_mame, 'names');
                     }
                 } else {
                     $attributes[$attr_mame] = $product->get_attribute($attr_mame);
                 }
             }
         }
         $send_product['attributes'] = $attributes;
         $send_product['total_variable_stock'] = $variable->get_total_stock();
         try {
             if (version_compare(WOOCOMMERCE_VERSION, '2.2', '>=')) {
                 if (function_exists('wc_get_product')) {
                     $original_product = wc_get_product($product->id);
                     if (is_object($original_product)) {
                         $send_product['visibility'] = $original_product->is_visible();
                         $send_product['product_type'] = $original_product->product_type;
                     }
                 }
             } else {
                 if (function_exists('get_product')) {
                     $original_product = get_product($product->id);
                     if (is_object($original_product)) {
                         $send_product['visibility'] = $original_product->is_visible();
                         $send_product['product_type'] = $original_product->product_type;
                     }
                 }
             }
         } catch (Exception $e) {
         }
     } catch (Exception $e) {
         $err_msg = "exception raised in attributes";
         self::send_error_report($err_msg);
     }
     if (!$woocommerce_ver_below_2_1) {
         try {
             $send_product['price_compare_at_price'] = $product->get_regular_price();
             $send_product['price_min'] = $variable->get_variation_price('min');
             $send_product['price_max'] = $variable->get_variation_price('max');
             $send_product['price_min_compare_at_price'] = $variable->get_variation_regular_price('min');
             $send_product['price_max_compare_at_price'] = $variable->get_variation_regular_price('max');
         } catch (Exception $e) {
             $send_product['price_compare_at_price'] = null;
             $send_product['price_min'] = null;
             $send_product['price_max'] = null;
             $send_product['price_min_compare_at_price'] = null;
             $send_product['price_max_compare_at_price'] = null;
         }
     } else {
         $send_product['price_compare_at_price'] = null;
         $send_product['price_min'] = null;
         $send_product['price_max'] = null;
         $send_product['price_min_compare_at_price'] = null;
         $send_product['price_max_compare_at_price'] = null;
     }
     $send_product['description'] = self::content_filter_shortcode_with_content($send_product['description']);
     $send_product['short_description'] = self::content_filter_shortcode_with_content($send_product['short_description']);
     $send_product['description'] = self::content_filter_shortcode($send_product['description']);
     $send_product['short_description'] = self::content_filter_shortcode($send_product['short_description']);
     try {
         if (defined('ICL_SITEPRESS_VERSION') && is_plugin_active('woocommerce-multilingual/wpml-woocommerce.php') && function_exists('wpml_get_language_information')) {
             if (version_compare(ICL_SITEPRESS_VERSION, '3.2', '>=')) {
                 $language_info = apply_filters('wpml_post_language_details', NULL, $post_id);
             } else {
                 $language_info = wpml_get_language_information($post_id);
             }
             if ($language_info && is_array($language_info) && array_key_exists('locale', $language_info)) {
                 // WP_Error could be returned from wpml_get_language_information(...)
                 $send_product['lang'] = $language_info['locale'];
             }
         }
     } catch (Exception $e) {
     }
     return $send_product;
 }
 /**
  * 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());
 }
示例#26
0
 } else {
     $product = new WC_Product($ticket->ID);
 }
 $gmt_offset = get_option('gmt_offset') >= '0' ? ' +' . get_option('gmt_offset') : " " . get_option('gmt_offset');
 $gmt_offset = str_replace(array('.25', '.5', '.75'), array(':15', ':30', ':45'), $gmt_offset);
 $end_date = null;
 if (!empty($ticket->end_date)) {
     $end_date = strtotime($ticket->end_date . $gmt_offset);
 } else {
     $end_date = strtotime(tribe_get_end_date(get_the_ID(), false, 'Y-m-d G:i') . $gmt_offset);
 }
 $start_date = null;
 if (!empty($ticket->start_date)) {
     $start_date = strtotime($ticket->start_date . $gmt_offset);
 }
 if (!$product->is_in_stock() || (empty($start_date) || time() > $start_date) && (empty($end_date) || time() < $end_date)) {
     $is_there_any_product = true;
     echo sprintf("<input type='hidden' name='product_id[]' value='%d'>", $ticket->ID);
     echo "<tr class='no-border'>";
     echo "<td colspan='2' class='tickets_name'>";
     echo $ticket->name;
     echo "</td>";
     echo "</tr>";
     echo "<tr class='no-border'>";
     echo "<td class='woocommerce'>";
     if ($product->is_in_stock()) {
         woocommerce_quantity_input(array('input_name' => 'quantity_' . $ticket->ID, 'input_value' => 0, 'min_value' => 0, 'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity()));
         $is_there_any_product_to_sell = true;
     } else {
         echo "<span class='tickets_nostock'>" . esc_html__('Out of stock!', 'tribe-wootickets') . "</span>";
     }