示例#1
0
 /**
  * Get the product thumbnail for the loop.
  *
  * @subpackage	Loop
  */
 function kt_template_loop_product_thumbnail()
 {
     echo kt_get_product_thumbnail();
 }
示例#2
0
    protected function content($atts, $content = null)
    {
        $atts = function_exists('vc_map_get_attributes') ? vc_map_get_attributes('product_sidebar', $atts) : $atts;
        $atts = shortcode_atts(array('title' => __('NEW PRODUCTS', 'kutetheme'), 'style' => 'style-1', 'target' => 'best-seller', 'orderby' => 'date', 'order' => 'DESC', 'ids' => '', 'taxonomy' => '', 'number_product' => 14, 'per_page' => 7, 'css_animation' => '', 'el_class' => '', 'css' => '', 'autoplay' => 'false', 'navigation' => 'false', 'margin' => 30, 'slidespeed' => 200, 'css' => '', 'el_class' => '', 'nav' => 'true', 'loop' => 'false'), $atts);
        extract($atts);
        global $woocommerce_loop;
        $is_phone = false;
        if (function_exists('kt_is_phone') && kt_is_phone()) {
            $is_phone = true;
        }
        $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, ' ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '));
        $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass));
        $elementClass = apply_filters('kt_product_sidebar_class_container', $elementClass);
        $tabs = array('best-sellers' => __('Best Sellers', 'kutetheme'), 'on-sales' => __('On Sales', 'kutetheme'), 'new-arrivals' => __('New Products', 'kutetheme'));
        $meta_query = WC()->query->get_meta_query();
        $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $number_product, 'meta_query' => $meta_query, 'suppress_filter' => true);
        if ($taxonomy) {
            $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => explode(",", $taxonomy)));
        }
        $data_carousel = array("autoplay" => $autoplay, "nav" => $navigation, "margin" => $margin, "smartSpeed" => $slidespeed, "theme" => 'style-navigation-bottom', "autoheight" => 'false', 'items' => 1, 'dots' => 'false', 'loop' => $loop, 'autoplayTimeout' => 1000, 'autoplayHoverPause' => 'true');
        if ($target == 'new-arrival') {
            $args['orderby'] = 'date';
            $args['order'] = 'DESC';
        } elseif ($target == 'on-sales') {
            $product_ids_on_sale = wc_get_product_ids_on_sale();
            $args['post__in'] = array_merge(array(0), $product_ids_on_sale);
            if ($orderby == '_sale_price') {
                $orderby = 'date';
                $order = 'DESC';
            }
            $args['orderby'] = $orderby;
            $args['order'] = $order;
        } elseif ($target == 'custom') {
            if ($orderby == '_sale_price') {
                $args['meta_query'] = array('relation' => 'OR', array('key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric'), array('key' => '_min_variation_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric'));
            } else {
                $args['orderby'] = $orderby;
                $args['order'] = $order;
            }
        } elseif ($target == 'most-review') {
            add_filter('posts_clauses', array($this, 'order_by_rating_post_clauses'));
        } elseif ($target == 'by-ids' && count($ids) > 0) {
            $args['post__in'] = $ids;
            $args['orderby'] = 'post__in';
        } else {
            $args['meta_key'] = 'total_sales';
            $args['orderby'] = 'meta_value_num';
        }
        $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
        if ($target == 'most-review') {
            remove_filter('posts_clauses', array($this, 'order_by_rating_post_clauses'));
        }
        remove_action('kt_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 10);
        $uniqeID = uniqid();
        ob_start();
        if ($products->have_posts()) {
            if ($style == 'style-1') {
                ?>
            <div class="block-new-product12 <?php 
                echo esc_attr($elementClass);
                ?>
">
                <?php 
                if ($title) {
                    ?>
                    <div class="title"><?php 
                    echo esc_html($title);
                    ?>
</div>
                <?php 
                }
                ?>
                <div class="inner owl-carousel" <?php 
                echo _data_carousel($data_carousel);
                ?>
>
                    <?php 
                $i = 1;
                ?>
                    <?php 
                while ($products->have_posts()) {
                    $products->the_post();
                    ?>
                    <?php 
                    if ($i == 1) {
                        ?>
                    <ul class="list-product">
                    <?php 
                    }
                    ?>
                        <li class="product">
                            <div class="image">
                                <a href="<?php 
                    the_permalink();
                    ?>
">
                                    <?php 
                    echo kt_get_product_thumbnail('shop_thumbnail');
                    ?>
                                </a>
                            </div>
                            <div class="info">
                                <h3 class="product-name"><a title="<?php 
                    echo esc_attr(get_the_title());
                    ?>
" href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    echo esc_attr(get_the_title());
                    ?>
</a></h3>
                                <?php 
                    /**
                     * woocommerce_after_shop_loop_item_title hook
                     * 
                     * @hooked woocommerce_template_loop_price - 5
                     * @hooked woocommerce_template_loop_rating - 10
                     */
                    do_action('kt_after_shop_loop_item_title');
                    ?>
                            </div>
                        </li>
                    <?php 
                    if ($i == $per_page) {
                        $i = 1;
                        echo '</ul><!--End Ul-->';
                    } else {
                        $i++;
                    }
                    ?>
                    
                    <?php 
                }
                ?>
                    <?php 
                if ($i > 1) {
                    ?>
                    </ul><!--./ End ul-->
                    <?php 
                }
                ?>
                </div>
            </div>
            <?php 
            } else {
                add_action('kt_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 10);
                ?>
                <div class="block-static option-14">
                    <?php 
                if ($title) {
                    ?>
                        <h3 class="title"><span><?php 
                    echo esc_html($title);
                    ?>
</span></h3>
                    <?php 
                }
                ?>
                    <div class="block-static-products owl-carousel" <?php 
                echo _data_carousel($data_carousel);
                ?>
>
                        <?php 
                $i = 1;
                ?>
                        <?php 
                while ($products->have_posts()) {
                    $products->the_post();
                    ?>
                        <?php 
                    if ($i == 1) {
                        ?>
                        <ul class="list">
                        <?php 
                    }
                    ?>
                            <li>
                                <div class="product-thumb">
                                    <a href="<?php 
                    the_permalink();
                    ?>
">
                                        <?php 
                    echo kt_get_product_thumbnail('shop_thumbnail');
                    ?>
                                    </a>
                                </div>
                                <div class="product-info">
                                    <h3 class="product-name">
                                        <a title="<?php 
                    echo esc_attr(get_the_title());
                    ?>
" href="<?php 
                    the_permalink();
                    ?>
">
                                            <?php 
                    echo esc_attr(get_the_title());
                    ?>
                                        </a>
                                    </h3>
                                    <?php 
                    /**
                     * woocommerce_after_shop_loop_item_title hook
                     * 
                     * @hooked woocommerce_template_loop_price - 5
                     * @hooked woocommerce_template_loop_rating - 10
                     */
                    do_action('kt_after_shop_loop_item_title');
                    ?>
                                    <div class="group-button-control">
                                        <?php 
                    woocommerce_template_loop_add_to_cart();
                    ?>
                                        <?php 
                    kt_get_tool_wishlish();
                    ?>
                                        <?php 
                    kt_get_tool_compare();
                    ?>
                                        <?php 
                    kt_get_tool_quickview();
                    ?>
                                    </div>
                                </div>
                            </li>
                            
                        <?php 
                    if ($i == $per_page) {
                        $i = 1;
                        echo '</ul><!--End Ul-->';
                    } else {
                        $i++;
                    }
                    ?>
                        <?php 
                }
                ?>
                        <?php 
                if ($i > 1) {
                    ?>
                        </ul><!--./ End ul-->
                        <?php 
                }
                ?>
                    </div>
                </div>
            <?php 
            }
        }
        add_action('kt_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 10);
        wp_reset_query();
        wp_reset_postdata();
        return ob_get_clean();
    }