Esempio n. 1
0
    protected function content($atts, $content = null)
    {
        $atts = function_exists('vc_map_get_attributes') ? vc_map_get_attributes('top_seller', $atts) : $atts;
        $atts = shortcode_atts(array('title' => __('Top Sellers', 'edo'), 'icon' => '', 'per_page' => 4, 'taxonomy' => '', 'autoplay' => 'false', 'navigation' => 'false', 'margin' => 30, 'slidespeed' => 250, 'nav' => 'true', 'loop' => 'true', 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts);
        extract($atts);
        ob_start();
        $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'block block-top-sellers ', $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));
        $meta_query = WC()->query->get_meta_query();
        $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'meta_query' => $meta_query, 'suppress_filter' => true, 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num');
        if ($taxonomy) {
            $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => explode(",", $taxonomy)));
        }
        $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
        if ($products->have_posts()) {
            $new_title = trim($title);
            $new_title = explode(' ', $new_title);
            if (count($new_title) > 1) {
                $title_sm = $new_title[0];
                unset($new_title[0]);
                $title_lg = implode(' ', $new_title);
            } else {
                $title_sm = __('Top', 'edo');
                $title_lg = __('sellers', 'edo');
            }
            if (intval($icon) > 0) {
                $att_icon = wp_get_attachment_image_src($icon, array(43, 42));
                $att_icon_url = is_array($att_icon) ? esc_url($att_icon[0]) : $default_icon;
            } else {
                if (filter_var($icon, FILTER_VALIDATE_URL)) {
                    $att_icon_url = $icon;
                } else {
                    $att_icon_url = KUTETHEME_PLUGIN_URL . 'js_composer/imgs/top-seller-icon.png';
                }
            }
            // Check lopp
            if ($products->post_count <= 1) {
                $loop = 'false';
            }
            $data_carousel = array("autoplay" => $autoplay, "navigation" => $navigation, "margin" => $margin, "slidespeed" => $slidespeed, "theme" => 'style-navigation-top', "autoheight" => 'false', 'nav' => 'true', 'dots' => 'false', 'loop' => $loop, 'autoplayTimeout' => 1000, 'autoplayHoverPause' => 'true', 'items' => '1');
            ?>
        <!-- block  top sellers -->
		<div class="<?php 
            echo $elementClass;
            ?>
">
			<div class="block-head">
				<div class="block-title">
					<div class="block-icon">
						<img alt="<?php 
            echo $title;
            ?>
" title="<?php 
            echo $title;
            ?>
" src="<?php 
            echo $att_icon_url;
            ?>
" />
					</div>
					<div class="block-title-text text-sm"><?php 
            echo esc_html($title_sm);
            ?>
</div>
					<div class="block-title-text text-lg"><?php 
            echo esc_html($title_lg);
            ?>
</div>
				</div>
			</div>
			<div class="block-inner">
				<?php 
            do_action("woocommerce_shortcode_before_top_seller_loop");
            ?>
					<ul class="products kt-owl-carousel" <?php 
            echo _data_carousel($data_carousel);
            ?>
>
                        <?php 
            while ($products->have_posts()) {
                $products->the_post();
                $id = get_the_ID();
                $link = get_permalink($id);
                ?>
                            <?php 
                edo_woocommerce_product_loop_item_before();
                ?>
    							<?php 
                wc_get_template_part('content', 'list-product');
                ?>
                            <?php 
                edo_woocommerce_product_loop_item_after();
                ?>
						<?php 
            }
            ?>
					</ul>
                <?php 
            do_action("woocommerce_shortcode_after_top_seller_loop");
            ?>
			</div>
		</div>
		<!-- block  top sellers -->
        <?php 
        }
        wp_reset_postdata();
        wp_reset_query();
        $result = ob_get_clean();
        return $result;
    }
Esempio n. 2
0
    /**
     * Loop product
     * @since edo 1.0
     */
    public function edo_loop_product($products, $data_carousel = '', $content = 'list-product-sidebar-1')
    {
        ?>
        <ul class="products kt-owl-carousel" <?php 
        echo $data_carousel;
        ?>
>
            <?php 
        while ($products->have_posts()) {
            $products->the_post();
            ?>
                <?php 
            edo_woocommerce_product_loop_item_before();
            ?>
					<?php 
            wc_get_template_part('content', $content);
            ?>
                <?php 
            edo_woocommerce_product_loop_item_after();
            ?>
			<?php 
        }
        ?>
		</ul>
        <?php 
        wp_reset_query();
        wp_reset_postdata();
    }
Esempio n. 3
0
    protected function content($atts, $content = null)
    {
        $atts = function_exists('vc_map_get_attributes') ? vc_map_get_attributes('list_product', $atts) : $atts;
        $atts = shortcode_atts(array('title' => __('Today\'s offers', 'edo'), 'icon' => '', 'ids' => '', 'orderby' => 'custom', 'order' => 'desc', 'per_page' => 4, 'autoplay' => 'false', 'navigation' => 'false', 'margin' => 30, 'slidespeed' => 200, 'nav' => 'true', 'loop' => 'true', 'use_responsive' => 0, 'items_destop' => 2, 'items_tablet' => 2, 'items_mobile' => 2, 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts);
        extract($atts);
        ob_start();
        $ids = explode(',', $ids);
        if (count($ids) > 0) {
            $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'block block-offers ', $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));
            $meta_query = WC()->query->get_meta_query();
            $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'meta_query' => $meta_query, 'suppress_filter' => true, 'post__in' => $ids);
            if ($orderby == 'custom') {
                $args['orderby'] = 'post__in';
            } else {
                $args['orderby'] = $orderby;
                $args['order'] = $order;
            }
            $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
            if ($products->have_posts()) {
                $new_title = $title;
                $new_title = explode(',', $new_title);
                if (count($new_title) > 1) {
                    $title_sm = $new_title[0];
                    unset($new_title[0]);
                    $title_lg = implode(' ', $new_title);
                } else {
                    $title_sm = __('Today\'s', 'edo');
                    $title_lg = __('offers', 'edo');
                }
                $default_icon = KUTETHEME_PLUGIN_URL . 'js_composer/imgs/offers-icon.png';
                if (isset($icon) && $icon) {
                    $att_icon = wp_get_attachment_image_src($icon, array(37, 43));
                    $att_icon_url = is_array($att_icon) ? esc_url($att_icon[0]) : $default_icon;
                } else {
                    $att_icon_url = $default_icon;
                }
                $data_carousel = array("autoplay" => $autoplay, "navigation" => $navigation, "margin" => $margin, "slidespeed" => $slidespeed, "theme" => 'style-navigation-top', "autoheight" => 'false', 'nav' => 'true', 'dots' => 'false', 'loop' => $loop, 'autoplayTimeout' => 1000, 'autoplayHoverPause' => 'true');
                if (!$use_responsive) {
                    $arr = array('0' => array("items" => $items_mobile), '768' => array("items" => $items_tablet), '992' => array("items" => $items_destop));
                    $data_responsive = json_encode($arr);
                    $data_carousel["responsive"] = $data_responsive;
                } else {
                    $data_carousel['items'] = 2;
                }
                ?>
                <!-- block-offers -->
    			<div class="<?php 
                echo $elementClass;
                ?>
">
    				<div class="block-head">
    					<div class="block-title">
    						<div class="block-icon">
    							<img alt="<?php 
                echo $title;
                ?>
" title="<?php 
                echo $title;
                ?>
" src="<?php 
                echo $att_icon_url;
                ?>
" />
    						</div>
    						<div class="block-title-text text-sm"><?php 
                echo $title_sm;
                ?>
</div>
    						<div class="block-title-text text-lg"><?php 
                echo $title_lg;
                ?>
</div>
    					</div>
    				</div>
    				<div class="block-inner">
                        <?php 
                do_action("woocommerce_shortcode_before_list_product_loop");
                ?>
        					<ul class="products kt-owl-carousel" <?php 
                echo _data_carousel($data_carousel);
                ?>
>
                                <?php 
                while ($products->have_posts()) {
                    $products->the_post();
                    $id = get_the_ID();
                    $link = get_permalink($id);
                    ?>
                                    <?php 
                    edo_woocommerce_product_loop_item_before();
                    ?>
            							<?php 
                    wc_get_template_part('content', 'list-product');
                    ?>
                                    <?php 
                    edo_woocommerce_product_loop_item_after();
                    ?>
        						<?php 
                }
                ?>
        					</ul>
                        <?php 
                do_action("woocommerce_shortcode_after_list_product_loop");
                ?>
    				</div>
    			</div>
    			<!-- block-offers -->
            <?php 
            }
        }
        wp_reset_postdata();
        wp_reset_query();
        $result = ob_get_clean();
        return $result;
    }