Пример #1
2
        public function widget($args, $instance)
        {
            extract($args);
            extract($instance);
            $title = apply_filters('widget_title', $title);
            echo $before_widget;
            echo $before_title . $title . $after_title;
            $loop = pgl_woocommerce_query('deals', 1);
            ?>

                <div class="woocommerce">
                    <div class="inner-content">  
                            <?php 
            if ($loop->have_posts()) {
                while ($loop->have_posts()) {
                    $loop->the_post();
                    wc_get_template_part('content', 'product-deals');
                }
            }
            ?>
                    </div>
                </div>
            <?php 
            wp_reset_query();
            echo $after_widget;
        }
function clea_patrice_sold_out_shortcode($atts)
{
    // allow sold out products in the query...
    remove_action('pre_get_posts', 'clea_patrice_no_sold_out_in_shop');
    global $woocommerce_loop;
    extract(shortcode_atts(array('per_page' => '12', 'columns' => '3', 'orderby' => 'date', 'order' => 'desc'), $atts));
    $woocommerce_loop['columns'] = $columns;
    $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'orderby' => $orderby, 'order' => $order, 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_stock_status', 'value' => 'outofstock', 'compare' => '=')));
    // Buffer our contents
    ob_start();
    do_action('woocommerce_before_shop_loop');
    $loop = new WP_Query($args);
    if ($loop->have_posts()) {
        while ($loop->have_posts()) {
            $loop->the_post();
            wc_get_template_part('content', 'product');
        }
    } else {
        echo __('No products found');
    }
    wp_reset_postdata();
    do_action('woocommerce_after_shop_loop');
    // Return buffered contents
    return '<ul class="products">' . ob_get_clean() . '</ul>';
}
 function ro_woocommerce_content()
 {
     if (is_singular('product')) {
         wc_get_template_part('single', 'product');
     } else {
         wc_get_template_part('archive', 'product');
     }
 }
Пример #4
0
/** Add Shop Header */
function spyropress_wc_shop_header()
{
    if (is_single()) {
        return;
    }
    wc_get_template_part('global/shop', 'header');
}
Пример #5
0
    protected function content($atts, $content = null)
    {
        $atts = function_exists('vc_map_get_attributes') ? vc_map_get_attributes('lastest_deals_sidebar', $atts) : $atts;
        $atts = shortcode_atts(array('title' => '', 'taxonomy' => '', 'number' => 12, 'autoplay' => "false", 'navigation' => "false", 'slidespeed' => 250, 'loop' => "false", 'items' => 1, 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts);
        extract($atts);
        $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'latest-deals ', $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_lastest_deals_sidebar_class_container', $elementClass);
        // Get products on sale
        $product_ids_on_sale = wc_get_product_ids_on_sale();
        $meta_query = WC()->query->get_meta_query();
        $args = array('posts_per_page' => $number, 'post_type' => 'product', 'orderby' => 'meta_value_num', 'meta_key' => '_sale_price_dates_to', 'order' => 'DESC', 'no_found_rows' => 1, 'post_status' => 'publish', 'meta_query' => $meta_query, 'post__in' => array_merge(array(0), $product_ids_on_sale));
        if ($taxonomy) {
            $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => explode(",", $taxonomy)));
        }
        $q = apply_filters('woocommerce_shortcode_products_query', $args, $atts);
        $query = new WP_Query($q);
        global $woocommerce_loop;
        ob_start();
        if ($query->have_posts()) {
            $data_carousel = array("autoplay" => $autoplay, "navigation" => $navigation, "slidespeed" => $slidespeed, "autoheight" => "false", "loop" => $loop, "dots" => "false", 'nav' => "true", "autoplayTimeout" => 1000, "autoplayHoverPause" => "true", 'items' => 1);
            add_filter("woocommerce_get_price_html_from_to", "kt_get_price_html_from_to", 10, 4);
            add_filter('woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2);
            ?>
            <div class="<?php 
            echo esc_attr($elementClass);
            ?>
">
                <h2 class="latest-deal-title"><?php 
            echo esc_html($title);
            ?>
</h2>
                <div class="latest-deal-content">
                    <ul class="product-list owl-carousel" <?php 
            echo _data_carousel($data_carousel);
            ?>
>
                        <?php 
            add_filter("woocommerce_get_price_html_from_to", "kt_get_price_html_from_to", 10, 4);
            while ($query->have_posts()) {
                $query->the_post();
                wc_get_template_part('content', 'product-sidebar');
            }
            // end of the loop.
            remove_filter("woocommerce_get_price_html_from_to", "kt_get_price_html_from_to", 10, 4);
            ?>
                    </ul>
                </div>
            </div>
            <?php 
            remove_filter("woocommerce_get_price_html_from_to", "kt_get_price_html_from_to", 10, 4);
            remove_filter('woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2);
        }
        wp_reset_postdata();
        wp_reset_query();
        $result = ob_get_contents();
        ob_clean();
        return $result;
    }
Пример #6
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' => '', 'cat' => 0, 'number' => 4, 'types' => 'sale', 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts);
        extract($atts);
        global $woocommerce_loop;
        $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'popular-tabs ', $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));
        ob_start();
        $meta_query = WC()->query->get_meta_query();
        $query = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $number, 'meta_query' => $meta_query);
        global $woocommerce_loop;
        $woocommerce_loop['columns'] = $number;
        if ($cat > 0) {
            $query['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $cat));
        }
        if ($types == 'arrival') {
            $query['orderby'] = 'date';
            $query['order'] = 'DESC';
        }
        if ($types == 'sale') {
            $product_ids_on_sale = wc_get_product_ids_on_sale();
            $query['meta_key'] = 'total_sales';
            $query['orderby'] = 'meta_value_num';
            $query['post__in'] = array_merge(array(0), $product_ids_on_sale);
        }
        if ($types == 'review') {
            add_filter('posts_clauses', array($this, 'order_by_rating_post_clauses'));
        }
        $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $query, $atts));
        if ($types == 'review') {
            remove_filter('posts_clauses', array($this, 'order_by_rating_post_clauses'));
        }
        if ($products->have_posts()) {
            ?>
        <div class="mega-group">
            <h4 class="mega-group-header"><span><?php 
            echo esc_html($title);
            ?>
</span></h4>
            <div class="mega-products">
                <?php 
            while ($products->have_posts()) {
                $products->the_post();
                ?>
                    <?php 
                wc_get_template_part('content', 'product-verticalmenu');
                ?>
                <?php 
            }
            // end of the loop.
            ?>
            </div>
        </div>  
        <?php 
        }
        return ob_get_clean();
    }
Пример #7
0
 protected function content($atts, $content = null)
 {
     $atts = shortcode_atts(array('product_type' => 'classic', 'product_effect' => '', 'desktop' => 4, 'per_page' => 10, 'orderby' => 'date', 'meta_key' => '', 'order' => 'DESC', 'source' => 'all', 'categories' => '', 'products' => '', 'operator' => 'IN', 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts);
     extract($atts);
     $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'cruxstore-products', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '), 'product_stype' => 'cruxstore-products-' . $product_type, 'woocommerce' => 'woocommerce columns-' . $desktop);
     $meta_query = WC()->query->get_meta_query();
     if ($source == 'best-sellers') {
         $meta_key = 'total_sales';
         $orderby = 'meta_value_num';
     }
     $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'meta_query' => $meta_query, 'order' => $order, 'orderby' => $orderby, 'meta_key' => $meta_key);
     if ($source == 'onsale') {
         $product_ids_on_sale = wc_get_product_ids_on_sale();
         $args['post__in'] = array_merge(array(0), $product_ids_on_sale);
     } elseif ($source == 'featured') {
         $args['meta_query'][] = array('key' => '_featured', 'value' => 'yes');
     } elseif ($source == 'top-rated') {
         add_filter('posts_clauses', array(__CLASS__, 'order_by_rating_post_clauses'));
     } elseif ($source == 'categories') {
         if (!empty($categories)) {
             $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array_map('sanitize_title', explode(',', $categories)), 'field' => 'slug', 'operator' => $operator));
         }
     } elseif ($source == 'products') {
         if (!empty($atts['products'])) {
             $args['post__in'] = array_map('trim', explode(',', $atts['products']));
         }
     }
     $output = '';
     ob_start();
     global $woocommerce_loop;
     $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
     if ($product_type != 'classic') {
         $product_effect = '';
     }
     $woocommerce_loop['columns'] = $desktop;
     $woocommerce_loop['type'] = $product_type;
     $woocommerce_loop['effect'] = $product_effect;
     if ($products->have_posts()) {
         woocommerce_product_loop_start();
         if ($product_type == 'masonry') {
             echo '<div class="clearfix product col-sm-3 grid-sizer"></div>';
         }
         while ($products->have_posts()) {
             $products->the_post();
             wc_get_template_part('content', 'product');
         }
         // end of the loop.
         woocommerce_product_loop_end();
     }
     wp_reset_postdata();
     if ($source == 'top-rated') {
         remove_filter('posts_clauses', array(__CLASS__, 'order_by_rating_post_clauses'));
     }
     $output .= ob_get_clean();
     $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass));
     return '<div class="' . esc_attr($elementClass) . '">' . $output . '</div>';
 }
Пример #8
0
    public function widget($args, $instance)
    {
        echo apply_filters('kt_wg_before_widget', $args['before_widget']);
        $title = isset($instance['title']) && $instance['title'] ? esc_html($instance['title']) : '';
        $orderby = isset($instance['orderby']) && $instance['orderby'] ? esc_attr($instance['orderby']) : 'date';
        $order = isset($instance['order']) && $instance['order'] ? esc_attr($instance['order']) : 'desc';
        $posts_per_page = isset($instance['posts_per_page']) && $instance['posts_per_page'] ? intval($instance['posts_per_page']) : '3';
        $meta_query = WC()->query->get_meta_query();
        $params = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $posts_per_page, 'meta_query' => $meta_query, 'suppress_filter' => true, 'orderby' => $orderby, 'order' => $order);
        if ($title) {
            echo apply_filters('kt_wg_before_title', $args['before_title']);
            echo esc_html($title);
            echo apply_filters('kt_wg_after_title', $args['after_title']);
        }
        $product = new WP_Query($params);
        ?>
        <!-- SPECIAL -->
        <div class="block left-module">
            <div class="block_content">
                <ul class="products-block">
                    <?php 
        if ($product->have_posts()) {
            ?>
                            <?php 
            while ($product->have_posts()) {
                $product->the_post();
                ?>
                                <?php 
                wc_get_template_part('content', 'special-product-sidebar');
                ?>
                            <?php 
            }
            ?>
                    <?php 
        }
        wp_reset_query();
        wp_reset_postdata();
        $shop_page_url = get_permalink(woocommerce_get_page_id('shop'));
        ?>
                </ul>
                <div class="products-block">
                    <div class="products-block-bottom">
                        <a class="link-all" href="<?php 
        echo esc_url($shop_page_url);
        ?>
"><?php 
        esc_html_e('All Products', 'kutetheme');
        ?>
</a>
                    </div>
                </div>
            </div>                            
        </div>
        <!-- ./SPECIAL -->
        <?php 
        echo apply_filters('kt_wg_after_widget', $args['after_widget']);
    }
Пример #9
0
 protected function content($atts, $content = null)
 {
     $atts = shortcode_atts(array('per_page' => 10, 'orderby' => 'date', 'meta_key' => '', 'order' => 'DESC', 'source' => '', 'categories' => '', 'products' => '', 'operator' => 'IN', 'layout' => 'normal', 'autoheight' => true, 'autoplay' => false, 'mousedrag' => true, 'autoplayspeed' => 5000, 'slidespeed' => 200, 'carousel_skin' => '', 'desktop' => 4, 'desktopsmall' => 3, 'tablet' => 2, 'mobile' => 1, 'gutters' => false, 'navigation' => true, 'navigation_always_on' => false, 'navigation_position' => 'center-outside', 'navigation_style' => 'normal', 'pagination' => false, 'pagination_position' => 'center-bottom', 'pagination_style' => 'dot-stroke', 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts);
     extract($atts);
     $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'products-carousel ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'woocommerce' => 'woocommerce columns-' . $desktop, 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '), 'layout' => 'layout-' . $layout);
     $meta_query = WC()->query->get_meta_query();
     if ($source == 'best-sellers') {
         $meta_key = 'total_sales';
         $orderby = 'meta_value_num';
     }
     $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'meta_query' => $meta_query, 'order' => $order, 'orderby' => $orderby, 'meta_key' => $meta_key);
     if ($source == 'onsale') {
         $product_ids_on_sale = wc_get_product_ids_on_sale();
         $args['post__in'] = array_merge(array(0), $product_ids_on_sale);
     } elseif ($source == 'featured') {
         $args['meta_query'][] = array('key' => '_featured', 'value' => 'yes');
     } elseif ($source == 'top-rated') {
         add_filter('posts_clauses', array(__CLASS__, 'order_by_rating_post_clauses'));
     } elseif ($source == 'categories') {
         if (!empty($categories)) {
             $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array_map('sanitize_title', explode(',', $categories)), 'field' => 'slug', 'operator' => $operator));
         }
     } elseif ($source == 'products') {
         if (!empty($atts['products'])) {
             $args['post__in'] = array_map('trim', explode(',', $atts['products']));
         }
     }
     $output = $carousel_html = '';
     ob_start();
     $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
     if ($products->have_posts()) {
         global $woocommerce_loop;
         $woocommerce_loop['columns'] = $desktop;
         $carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $atts), '', 'wc-carousel-wrapper');
         if ($layout == 'transparent') {
             $woocommerce_loop['type'] = 'transparent';
         } else {
             $woocommerce_loop['type'] = 'normal';
         }
         woocommerce_product_loop_start();
         while ($products->have_posts()) {
             $products->the_post();
             wc_get_template_part('content', 'product');
         }
         // end of the loop.
         woocommerce_product_loop_end();
     }
     $carousel_html .= ob_get_clean();
     wp_reset_postdata();
     if ($carousel_html) {
         $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass));
         $output = '<div class="' . esc_attr($elementClass) . '">' . str_replace('%carousel_html%', $carousel_html, $carousel_ouput) . '</div>';
     }
     return $output;
 }
Пример #10
0
 /**
  * This method is used to display the output of the element.
  * @return void
  */
 function element()
 {
     // Prevent the elemnt from being accessible on other pages
     if (!is_singular('product')) {
         echo '<div class="zn-pb-notification">This element only works on single product pages created with WooCommerce. Please delete it.</div>';
         return false;
     }
     echo '<div class="zn_post_content_elemenent ' . $this->data['uid'] . ' ' . $this->opt('css_class', '') . '">';
     wc_get_template_part('content', 'single-product');
     echo '</div>';
 }
Пример #11
0
 public function widget($args, $instance)
 {
     echo apply_filters('kt_wg_before_widget', $args['before_widget']);
     $title = isset($instance['title']) && $instance['title'] ? esc_html($instance['title']) : '';
     $number = isset($instance['number']) && intval($instance['number']) ? intval($instance['number']) : 3;
     $orderby = isset($instance['orderby']) && $instance['orderby'] ? esc_attr($instance['orderby']) : 'date';
     $order = isset($instance['order']) && $instance['order'] ? esc_attr($instance['order']) : 'desc';
     $meta_query = WC()->query->get_meta_query();
     $product_ids_on_sale = wc_get_product_ids_on_sale();
     $params = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $number, 'meta_query' => $meta_query, 'suppress_filter' => true, 'orderby' => $orderby, 'order' => $order, 'post__in' => array_merge(array(0), $product_ids_on_sale));
     $product = new WP_Query($params);
     if ($product->have_posts()) {
         ?>
     <!-- block best sellers -->
     <div class="block left-module">
         <?php 
         if ($title) {
             echo apply_filters('kt_wg_before_title', $args['before_title']);
             echo esc_html($title);
             echo apply_filters('kt_wg_after_title', $args['after_title']);
         }
         add_filter('woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2);
         add_filter("woocommerce_get_price_html_from_to", "kt_get_price_html_from_to", 10, 4);
         ?>
         <div class="block_content product-onsale">
             <ul class="product-list owl-carousel" data-loop="false" data-nav = "false" data-margin = "0" data-autoplayTimeout="1000" data-autoplayHoverPause = "true" data-items="1" data-autoplay="false">
                 <?php 
         while ($product->have_posts()) {
             $product->the_post();
             ?>
                     <li>
                         <?php 
             wc_get_template_part('content', 'on-sale-sidebar');
             ?>
                     </li>
                 <?php 
         }
         ?>
             </ul>
         </div>
         <?php 
         remove_filter("woocommerce_get_price_html_from_to", "kt_get_price_html_from_to", 10, 4);
         remove_filter('woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2);
         ?>
     </div>
     <!-- ./block best sellers  -->
     <?php 
     }
     echo apply_filters('kt_wg_after_widget', $args['after_widget']);
 }
Пример #12
0
 /**
  * Filter that replaces current woocommerce template with template defined in settings.
  *
  * @see beforeWCTemplateRender
  * @param  string $file full path to currently rendered template
  * @return mixed
  */
 public static function filter_wc_template_rendering($file)
 {
     if ($file && self::isTourProduct()) {
         $anotherTemplate = '';
         $map = self::$wcTemplatesMap;
         $baseName = basename($file, '.php');
         if (isset($map[$baseName])) {
             wc_get_template_part($map[$baseName]);
             // get_template_part($map[$baseName]);
             return false;
         }
     }
     return $file;
 }
Пример #13
0
function nm_ajax_load_product()
{
    global $woocommerce, $product, $post;
    //$post = $product = get_post( $_POST['product_id'] );
    $product = get_product($_POST['product_id']);
    $post = $product->post;
    $output = '';
    setup_postdata($post);
    ob_start();
    wc_get_template_part('quickview/content', 'quickview');
    $output = ob_get_clean();
    wp_reset_postdata();
    echo $output;
    exit;
}
Пример #14
0
function pgl_woocommerce_switch_layout_ajax()
{
    $args = json_decode(base64_decode($_POST['query']));
    $type = $_POST['type'];
    $query = new WP_Query($args);
    query_posts($args);
    while ($query->have_posts()) {
        $query->the_post();
        if ($type == 'list') {
            wc_get_template_part('content', 'product-list');
        } else {
            wc_get_template_part('content', 'product');
        }
    }
    die;
}
Пример #15
0
function new_products_lightspeed($atts)
{
    /**
     * Featured Products shortcode
     *
     * @param array $atts
     * @return string
     */
    global $woocommerce_loop, $products, $product;
    // include our handy API wrapper that makes it easy to call the API, it also depends on MOScURL to make the cURL call
    require_once "MOSAPICall.class.php";
    extract(shortcode_atts(array('per_page' => '12', 'columns' => '4', 'orderby' => 'date', 'order' => 'desc'), $atts));
    $woocommerce_loop['columns'] = $columns;
    ob_start();
    $mosapi = new MOSAPICall("992e498dfa5ab5245f5bd5afee4ee1ce6ac6e0a1ee7d11e36480694a9b5282e7", "83442");
    $emitter = 'https://api.merchantos.com/API/Account/83442/ItemMatrix';
    $xml_query_string = 'limit=100&orderby=timeStamp&orderby_desc=1&load_relations=["ItemECommerce","Tags","Images"]';
    $products = $mosapi->makeAPICall("Account.ItemMatrix", "Read", null, null, $emitter, $xml_query_string);
    $wp_session = WP_Session::get_instance();
    $products = xml2array($products);
    $wp_session['products'] = $products;
    //var_dump($wp_session['products']);
    $i = 0;
    //if ( $products->children() ) :
    ?>

		<?php 
    woocommerce_product_loop_start();
    ?>

			<?php 
    foreach ($products as $prod) {
        foreach ($prod as $product) {
            wc_get_template_part('content', 'lightspeedproduct');
        }
    }
    // end of the loop.
    ?>

		<?php 
    woocommerce_product_loop_end();
    ?>

	<?php 
    //endif;
    return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
}
Пример #16
0
function frar_display_products()
{
    $ul = '<ul id="list" class="products">';
    $args = array('post_type' => 'product', 'posts_per_page' => 2);
    $loop = new WP_Query($args);
    if ($loop->have_posts()) {
        while ($loop->have_posts()) {
            $loop->the_post();
            // var_dump($loop->the_post());
            wc_get_template_part('content', 'product');
        }
    } else {
        echo __('No products found');
    }
    wp_reset_postdata();
    $ul .= '</ul>';
    return $ul;
}
    public function widget($args, $instance)
    {
        echo $args['before_widget'];
        $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
        $orderby = isset($instance['orderby']) ? $instance['orderby'] : 'date';
        $order = isset($instance['order']) ? $instance['order'] : 'desc';
        $meta_query = WC()->query->get_meta_query();
        $params = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => 1, 'meta_query' => $meta_query, 'suppress_filter' => true, 'orderby' => $orderby, 'order' => $order);
        $product = new WP_Query($params);
        ?>
        <!-- SPECIAL -->
        <div class="block left-module">
            <p class="title_block"><?php 
        echo $title;
        ?>
</p>
            <?php 
        if ($product->have_posts()) {
            ?>
                <?php 
            while ($product->have_posts()) {
                $product->the_post();
                ?>
                    <?php 
                wc_get_template_part('content', 'special-product-sidebar');
                ?>
                <?php 
            }
            ?>
            <?php 
        }
        wp_reset_query();
        wp_reset_postdata();
        ?>
        </div>
        <!-- ./SPECIAL -->
        <?php 
        echo $args['after_widget'];
    }
Пример #18
0
 protected function content($atts, $content = null)
 {
     $atts = shortcode_atts(array('desktop' => 3, 'per_page' => 10, 'orderby' => 'date', 'meta_key' => '', 'order' => 'DESC', 'source' => 'all', 'categories' => '', 'products' => '', 'operator' => 'IN', 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts);
     extract($atts);
     $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'cruxstore-products-countdown', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'woocommerce' => 'woocommerce columns-' . $desktop, 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '));
     $meta_query = WC()->query->get_meta_query();
     $product_ids_on_sale = wc_get_product_ids_on_sale();
     $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $atts['per_page'], 'meta_query' => $meta_query, 'order' => $order, 'orderby' => $orderby, 'meta_key' => $meta_key, 'post__in' => array_merge(array(0), $product_ids_on_sale));
     if ($source == 'categories') {
         if (!empty($categories)) {
             $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array_map('sanitize_title', explode(',', $categories)), 'field' => 'slug', 'operator' => $operator));
         }
     } elseif ($source == 'products') {
         if (!empty($atts['products'])) {
             $args['post__in'] = array_map('trim', explode(',', $atts['products']));
         }
     }
     $output = '';
     ob_start();
     global $woocommerce_loop;
     $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
     $woocommerce_loop['columns'] = $desktop;
     $woocommerce_loop['type'] = 'countdown';
     if ($products->have_posts()) {
         woocommerce_product_loop_start();
         while ($products->have_posts()) {
             $products->the_post();
             wc_get_template_part('content', 'product_sale');
         }
         // end of the loop.
         woocommerce_product_loop_end();
     }
     wp_reset_postdata();
     $output .= ob_get_clean();
     $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass));
     return '<div class="' . esc_attr($elementClass) . '">' . $output . '</div>';
 }
Пример #19
0
            <h4><?php 
        _e('Complete the look', 'captiva');
        ?>
</h4>
    <?php 
    }
    ?>

        <ul class="up-sell-grid"> 

            <?php 
    while ($products->have_posts()) {
        $products->the_post();
        ?>

                <?php 
        wc_get_template_part('content', 'product-upsells');
        ?>

    <?php 
    }
    // end of the loop.
    ?>

        </ul>

    </div>

<?php 
}
wp_reset_postdata();
Пример #20
0
<?php

/**
 * Checkout Form
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.0.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
echo '<hr class="tall" />';
wc_get_template_part('checkout/header');
wc_print_notices();
do_action('woocommerce_before_checkout_form', $checkout);
// If checkout registration is disabled and not logged in, the user cannot checkout
if (!$checkout->enable_signup && !$checkout->enable_guest_checkout && !is_user_logged_in()) {
    echo apply_filters('woocommerce_checkout_must_be_logged_in_message', __('You must be logged in to checkout.', 'woocommerce'));
    return;
}
// filter hook for include new pages inside the payment method
$get_checkout_url = apply_filters('woocommerce_get_checkout_url', WC()->cart->get_checkout_url());
?>


<div class="row">
    <div class="col-md-9">
        <form name="checkout" method="post" class="checkout" action="<?php 
echo esc_url($get_checkout_url);
Пример #21
0
        ?>
                    <div id="<?php 
        echo 'tab-' . $id . '-' . $i;
        ?>
" class="tab-panel <?php 
        echo $i == 0 ? 'active' : '';
        ?>
" >
                        <ul class="tab-products">
                            <?php 
        while ($products->have_posts()) {
            $products->the_post();
            ?>
                                <li class="product-style3">
                                    <?php 
            wc_get_template_part('content', 'product-tab12');
            ?>
                                </li>
                            <?php 
        }
        // end of the loop.
        ?>
                        </ul>
                    </div>
                    <?php 
        $i++;
        ?>
                    <?php 
    }
    ?>
                    <?php 
    /**
     * Output WooCommerce content.
     *
     * This function is only used in the optional 'woocommerce.php' template
     * which people can add to their themes to add basic woocommerce support
     * without hooks or modifying core templates.
     *
     * @access public
     * @return void
     */
    function woocommerce_content()
    {
        if (is_singular('product')) {
            while (have_posts()) {
                the_post();
                wc_get_template_part('content', 'single-product');
            }
        } else {
            ?>

			<?php 
            if (apply_filters('woocommerce_show_page_title', true)) {
                ?>

				<h1 class="page-title"><?php 
                woocommerce_page_title();
                ?>
</h1>

			<?php 
            }
            ?>

			<?php 
            do_action('woocommerce_archive_description');
            ?>

			<?php 
            if (have_posts()) {
                ?>

				<?php 
                do_action('woocommerce_before_shop_loop');
                ?>

				<?php 
                woocommerce_product_loop_start();
                ?>

					<?php 
                woocommerce_product_subcategories();
                ?>

					<?php 
                while (have_posts()) {
                    the_post();
                    ?>

						<?php 
                    wc_get_template_part('content', 'product');
                    ?>

					<?php 
                }
                // end of the loop.
                ?>

				<?php 
                woocommerce_product_loop_end();
                ?>

				<?php 
                do_action('woocommerce_after_shop_loop');
                ?>

			<?php 
            } elseif (!woocommerce_product_subcategories(array('before' => woocommerce_product_loop_start(false), 'after' => woocommerce_product_loop_end(false)))) {
                ?>

				<?php 
                wc_get_template('loop/no-products-found.php');
                ?>

			<?php 
            }
        }
    }
 function wfsm_save()
 {
     if ((defined('DOING_AJAX') && DOING_AJAX) === false) {
         die('Error!');
         exit;
     }
     if (isset($_POST) && isset($_POST['wfsm_id'])) {
         $curr_post_id = absint(stripslashes($_POST['wfsm_id']));
         if (get_post_status($curr_post_id) === false) {
             die('Error!');
             exit;
         }
     } else {
         die('Error!');
         exit;
     }
     $curr_post_author = absint(get_post_field('post_author', $curr_post_id));
     if (!current_user_can('edit_product', array('ID' => $curr_post_id)) || !isset(self::$settings['admin_mode']) && $curr_post_author !== self::$settings['user']->ID) {
         die('Error!');
         exit;
     }
     $curr_data = array();
     $curr_data = json_decode(stripslashes($_POST['wfsm_save']), true);
     $curr_post = array('ID' => $curr_post_id, 'post_title' => $curr_data['wfsm-product-name']);
     wp_update_post($curr_post);
     if (isset($curr_data['wfsm-featured-image'])) {
         $curr_val = intval(stripslashes($curr_data['wfsm-featured-image']));
         if (wp_attachment_is_image($curr_val)) {
             update_post_meta($curr_post_id, '_thumbnail_id', $curr_val);
         }
     }
     if (isset($curr_data['wfsm-regular-price']) && $curr_data['wfsm-regular-price'] !== '') {
         update_post_meta($curr_post_id, '_regular_price', intval($curr_data['wfsm-regular-price']));
         if (intval($curr_data['wfsm-sale-price']) == '') {
             update_post_meta($curr_post_id, '_price', intval($curr_data['wfsm-regular-price']));
         }
     } else {
         if (isset($curr_data['wfsm-regular-price']) && $curr_data['wfsm-regular-price'] == '') {
             update_post_meta($curr_post_id, '_regular_price', '');
         }
     }
     if (isset($curr_data['wfsm-sale-price']) && $curr_data['wfsm-sale-price'] !== '') {
         update_post_meta($curr_post_id, '_sale_price', intval($curr_data['wfsm-sale-price']));
         update_post_meta($curr_post_id, '_price', intval($curr_data['wfsm-sale-price']));
     } else {
         if (isset($curr_data['wfsm-sale-price']) && $curr_data['wfsm-sale-price'] == '') {
             update_post_meta($curr_post_id, '_sale_price', '');
         }
     }
     if (isset($curr_data['wfsm-select-product_cat']) && $curr_data['wfsm-select-product_cat'] !== null && is_array($curr_data['wfsm-select-product_cat'])) {
         $add_terms = array();
         $ready_array = array_map('sanitize_text_field', $curr_data['wfsm-select-product_cat']);
         foreach ($ready_array as $curr_tax) {
             $curr_slug = sanitize_title($curr_tax);
             if (!get_term_by('slug', $curr_slug, 'product_cat')) {
                 wp_insert_term($curr_tax, 'product_cat', array('slug' => $curr_tax));
             }
             $add_terms[] = $curr_slug;
         }
         wp_set_object_terms($curr_post_id, $add_terms, 'product_cat');
     } else {
         wp_set_object_terms($curr_post_id, array(), 'product_cat');
     }
     $curr_loop = isset($_POST['wfsm_loop']) ? sanitize_text_field($_POST['wfsm_loop']) : 'single';
     if ($curr_loop !== 'single') {
         $wfsm_settings = strpos($curr_loop, '|') ? explode('|', $curr_loop) : 'single';
         if (is_array($wfsm_settings)) {
             global $woocommerce_loop;
             $woocommerce_loop = array('loop' => intval($wfsm_settings[0]) - 1, 'columns' => intval($wfsm_settings[1]));
             $curr_products = new WP_Query(array('post_type' => 'product', 'post__in' => array($curr_post_id)));
             ob_start();
             if ($curr_products->have_posts()) {
                 while ($curr_products->have_posts()) {
                     $curr_products->the_post();
                     wc_get_template_part('content', 'product');
                 }
             }
             $out = ob_get_clean();
         } else {
             $out = 'single';
         }
     } else {
         $out = 'single';
     }
     die($out);
     exit;
 }
Пример #24
0
    public function woof_products($atts)
    {
        $_REQUEST['woof_products_doing'] = 1;
        add_filter('posts_where', array($this, 'woof_post_title_filter'), 9999);
        $shortcode_txt = 'woof_products';
        if (!empty($atts)) {
            foreach ($atts as $key => $value) {
                $shortcode_txt .= ' ' . $key . '=' . $value;
            }
        }
        //***
        $data = $this->get_request_data();
        $catalog_orderby = $this->get_catalog_orderby(isset($data['orderby']) ? $data['orderby'] : '');
        extract(shortcode_atts(array('columns' => apply_filters('loop_shop_columns', 4), 'orderby' => $catalog_orderby['orderby'], 'order' => $catalog_orderby['order'], 'page' => 1, 'per_page' => 0, 'is_ajax' => 0, 'taxonomies' => '', 'sid' => '', 'dp' => 0), $atts));
        //***
        //this needs just for AJAX mode for shortcode [woof] in woof_draw_products()
        $_REQUEST['woof_additional_taxonomies_string'] = $taxonomies;
        //+++
        $args = array('post_type' => 'product', 'post_status' => 'publish', 'orderby' => $orderby, 'order' => $order, 'meta_query' => $this->get_meta_query(), 'tax_query' => $this->get_tax_query($taxonomies));
        $args['posts_per_page'] = $this->settings['per_page'];
        if ($per_page > 0) {
            $args['posts_per_page'] = $per_page;
        } else {
            //compatibility for woocommerce-products-per-page
            if (WC()->session->__isset('products_per_page')) {
                $args['posts_per_page'] = WC()->session->__get('products_per_page');
            }
        }
        //Display Product for WooCommerce compatibility
        if (isset($_REQUEST['perpage'])) {
            $args['posts_per_page'] = $_REQUEST['perpage'];
        }
        //if smth wrong, set default per page option
        if (!$args['posts_per_page']) {
            $args['posts_per_page'] = $this->settings['per_page'];
        }
        //***
        if (!empty($catalog_orderby['meta_key'])) {
            $args['meta_key'] = $catalog_orderby['meta_key'];
            $args['orderby'] = $catalog_orderby['orderby'];
            if (!empty($catalog_orderby['order'])) {
                $args['order'] = $catalog_orderby['order'];
            }
        } else {
            $args['orderby'] = $catalog_orderby['orderby'];
            if (!empty($catalog_orderby['order'])) {
                $args['order'] = $catalog_orderby['order'];
            }
        }
        //print_r($args);
        //+++
        $pp = $page;
        if (get_query_var('page')) {
            $pp = get_query_var('page');
        }
        if (get_query_var('paged')) {
            $pp = get_query_var('paged');
        }
        if ($pp > 1) {
            $args['paged'] = $pp;
        } else {
            $args['paged'] = get_query_var('page') ? get_query_var('page') : $page;
        }
        //+++
        $wr = apply_filters('woocommerce_shortcode_products_query', $args, $atts);
        global $products, $wp_query;
        //print_r($wr);
        $_REQUEST['woof_wp_query'] = $wp_query = $products = new WP_Query($wr);
        $_REQUEST['woof_wp_query_args'] = $wr;
        //***
        ob_start();
        global $woocommerce_loop;
        $woocommerce_loop['columns'] = $columns;
        $woocommerce_loop['loop'] = 0;
        ?>

        <?php 
        if ($is_ajax == 1) {
            ?>
            <?php 
            //if (!get_option('woof_try_ajax')):
            ?>
            <div id="woof_results_by_ajax" class="woof_results_by_ajax_shortcode" data-shortcode="<?php 
            echo $shortcode_txt;
            ?>
">
            <?php 
            //endif;
            ?>
            <?php 
        }
        ?>
            <?php 
        if ($products->have_posts()) {
            add_filter('post_class', array($this, 'woo_post_class'));
            $_REQUEST['woof_before_shop_loop_done'] = true;
            ?>

                <div class="woocommerce columns-<?php 
            echo $columns;
            ?>
 woocommerce-page woof_shortcode_output">

            <?php 
            if ($dp == 0) {
                //Display Product for WooCommerce compatibility
                do_action('woocommerce_before_shop_loop');
            }
            ?>


            <?php 
            if (function_exists('woocommerce_product_loop_start')) {
                woocommerce_product_loop_start();
            }
            ?>

                    <?php 
            global $woocommerce_loop;
            $woocommerce_loop['columns'] = $columns;
            $woocommerce_loop['loop'] = 0;
            //+++
            wc_get_template('loop/loop-start.php');
            //WOOCS compatibility
            global $WOOCS;
            if (!method_exists($WOOCS, 'woocs_convert_currency')) {
                if (class_exists('WOOCS') and defined('DOING_AJAX')) {
                    //IT IS OBSOLETE AND NOT RIGHT ALREADY FROM X.0.9 VERSIONS
                    //add_filter('raw_woocommerce_price', array($this, 'raw_woocommerce_price'), 1001);
                    //add_filter('woocommerce_currency_symbol', array($this, 'woocommerce_currency_symbol'), 1001);
                }
            }
            ?>



            <?php 
            //products output
            if ($dp == 0) {
                //Display Product for WooCommerce compatibility
                while ($products->have_posts()) {
                    $products->the_post();
                    wc_get_template_part('content', 'product');
                }
                // end of the loop.
            } else {
                echo do_shortcode('[displayProduct id="' . $dp . '"]');
            }
            ?>



            <?php 
            wc_get_template('loop/loop-end.php');
            ?>

                    <?php 
            if (function_exists('woocommerce_product_loop_end')) {
                woocommerce_product_loop_end();
            }
            ?>

                    <?php 
            do_action('woocommerce_after_shop_loop');
            ?>

                </div>


            <?php 
        } else {
            if ($is_ajax == 1) {
                ?>
                        <div id="woof_results_by_ajax" class="woof_results_by_ajax_shortcode" data-shortcode="<?php 
                echo $shortcode_txt;
                ?>
">
                        <?php 
            }
            ?>
                    <div class="woocommerce woocommerce-page woof_shortcode_output">

            <?php 
            if (!$is_ajax) {
                wc_get_template('loop/no-products-found.php');
            } else {
                ?>
                            <div id="woof_results_by_ajax" class="woof_results_by_ajax_shortcode" data-shortcode="<?php 
                echo $shortcode_txt;
                ?>
">
                            <?php 
                wc_get_template('loop/no-products-found.php');
                ?>
                            </div>
                                <?php 
            }
            ?>

                    </div>
            <?php 
            if ($is_ajax == 1) {
                if (!get_option('woof_try_ajax', 0)) {
                    echo '</div>';
                }
            }
        }
        ?>

                <?php 
        if ($is_ajax == 1) {
            ?>
                    <?php 
            if (!get_option('woof_try_ajax', 0)) {
                ?>
                    </div>
                    <?php 
            }
            ?>
            <?php 
        }
        ?>
            <?php 
        wp_reset_postdata();
        wp_reset_query();
        unset($_REQUEST['woof_products_doing']);
        return ob_get_clean();
    }
Пример #25
0
    /**
     * List products with an attribute shortcode
     * Example [product_attribute attribute='color' filter='black']
     *
     * @param array $atts
     * @return string
     */
    public static function product_attribute($atts)
    {
        global $woocommerce_loop;
        $atts = shortcode_atts(array('per_page' => '12', 'columns' => '4', 'orderby' => 'title', 'order' => 'asc', 'attribute' => '', 'filter' => ''), $atts);
        $attribute = strstr($atts['attribute'], 'pa_') ? sanitize_title($atts['attribute']) : 'pa_' . sanitize_title($atts['attribute']);
        $meta_query = WC()->query->get_meta_query();
        $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $atts['per_page'], 'orderby' => $atts['orderby'], 'order' => $atts['order'], 'meta_query' => $meta_query, 'tax_query' => array(array('taxonomy' => $attribute, 'terms' => array_map('sanitize_title', explode(',', $atts['filter'])), 'field' => 'slug')));
        ob_start();
        $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
        $woocommerce_loop['columns'] = $atts['columns'];
        if ($products->have_posts()) {
            ?>

			<?php 
            woocommerce_product_loop_start();
            ?>

				<?php 
            while ($products->have_posts()) {
                $products->the_post();
                ?>

					<?php 
                wc_get_template_part('content', 'product');
                ?>

				<?php 
            }
            // end of the loop.
            ?>

			<?php 
            woocommerce_product_loop_end();
            ?>

		<?php 
        }
        wp_reset_postdata();
        return '<div class="woocommerce columns-' . $atts['columns'] . '">' . ob_get_clean() . '</div>';
    }
Пример #26
0
    protected function content($atts, $content = null)
    {
        $atts = function_exists('vc_map_get_attributes') ? vc_map_get_attributes('tab_producs', $atts) : $atts;
        $atts = shortcode_atts(array('taxonomy' => '', 'style' => '1', 'per_page' => 12, 'columns' => 4, 'border_heading' => '', 'css_animation' => '', 'el_class' => '', 'css' => '', 'autoplay' => 'false', 'navigation' => 'false', 'margin' => 30, 'slidespeed' => 200, 'css' => '', 'el_class' => '', 'nav' => 'true', 'loop' => 'false', 'use_responsive' => 1, 'items_destop' => 3, 'items_tablet' => 2, 'items_mobile' => 1), $atts);
        extract($atts);
        global $woocommerce_loop;
        $is_phone = false;
        if (function_exists('kt_is_phone') && kt_is_phone()) {
            $is_phone = true;
        }
        if ($style == 3) {
            $base_class = 'tab-product-13 option-13 style1 ';
        } else {
            $base_class = 'popular-tabs ';
        }
        $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $base_class, $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_tab_class_container', $elementClass);
        $tabs = array('best-sellers' => __('Best Sellers', 'edo'), 'on-sales' => __('On Sales', 'edo'), 'new-arrivals' => __('New Products', 'edo'));
        $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);
        if ($taxonomy) {
            $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => explode(",", $taxonomy)));
        }
        $uniqeID = uniqid();
        ob_start();
        ?>
        <div class="<?php 
        echo esc_attr($elementClass);
        ?>
 top-nav container-tab style<?php 
        echo esc_attr($style);
        ?>
">
            <ul class="nav-tab">
                <?php 
        $i = 0;
        ?>
                <?php 
        foreach ($tabs as $k => $v) {
            ?>
                    <li <?php 
            echo $i == 0 ? 'class="active"' : '';
            ?>
 >
                        <a data-toggle="tab" href="#tab-<?php 
            echo esc_attr($k) . $uniqeID;
            ?>
"><?php 
            echo esc_html($v);
            ?>
</a>
                    </li>
                    <?php 
            $i++;
            ?>
                <?php 
        }
        ?>
            </ul>
            <div class="tab-container">
                <?php 
        $data_carousel = array("autoplay" => $autoplay, "navigation" => $navigation, "margin" => $margin, "slidespeed" => $slidespeed, "theme" => 'style-navigation-bottom', "autoheight" => 'false', 'nav' => $navigation, '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 {
            if ($style == 3) {
                $data_carousel['items'] = 4;
            } else {
                $data_carousel['items'] = 3;
            }
        }
        $carousel = _data_carousel($data_carousel);
        $i = 0;
        ?>
                <?php 
        foreach ($tabs as $k => $v) {
            ?>
                    <?php 
            $newargs = $args;
            if ($k == 'best-sellers') {
                $newargs['meta_key'] = 'total_sales';
                $newargs['orderby'] = 'meta_value_num';
            } elseif ($k == 'on-sales') {
                $product_ids_on_sale = wc_get_product_ids_on_sale();
                $newargs['post__in'] = array_merge(array(0), $product_ids_on_sale);
                $newargs['orderby'] = 'date';
                $newargs['order'] = 'DESC';
            } else {
                $newargs['orderby'] = 'date';
                $newargs['order'] = 'DESC';
            }
            $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $newargs, $atts));
            if ($products->have_posts()) {
                ?>
                    <!-- Style 1 -->
                    <?php 
                if ($style == 1) {
                    ?>
                    <div id="tab-<?php 
                    echo esc_attr($k) . $uniqeID;
                    ?>
" class="tab-panel <?php 
                    echo $i == 0 ? 'active' : '';
                    ?>
">
                        <ul class="products kt-owl-carousel" <?php 
                    echo apply_filters('kt_shortcode_tab_product_carousel', $carousel);
                    ?>
>
                            <?php 
                    while ($products->have_posts()) {
                        $products->the_post();
                        ?>
                                <li class="product style6 no-hiden">
                                <?php 
                        wc_get_template_part('content', 'product-tab');
                        ?>
                                </li>
                            <?php 
                    }
                    ?>
                        </ul>
                    </div>
                    <!-- ./Style 1 -->
                    <?php 
                }
                ?>
                    <?php 
            }
            ?>
                    <?php 
            wp_reset_query();
            wp_reset_postdata();
            $i++;
            ?>
                <?php 
        }
        ?>
            </div>
        </div>
        <?php 
        return ob_get_clean();
    }
    /**
     * Show a single product page.
     *
     * @param array $atts
     * @return string
     */
    public static function product_page($atts)
    {
        if (empty($atts)) {
            return '';
        }
        if (!isset($atts['id']) && !isset($atts['sku'])) {
            return '';
        }
        $args = array('posts_per_page' => 1, 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'no_found_rows' => 1);
        if (isset($atts['sku'])) {
            $args['meta_query'][] = array('key' => '_sku', 'value' => sanitize_text_field($atts['sku']), 'compare' => '=');
            $args['post_type'] = array('product', 'product_variation');
        }
        if (isset($atts['id'])) {
            $args['p'] = absint($atts['id']);
        }
        $single_product = new WP_Query($args);
        $preselected_id = '0';
        // check if sku is a variation
        if (isset($atts['sku']) && $single_product->have_posts() && $single_product->post->post_type === 'product_variation') {
            $variation = new WC_Product_Variation($single_product->post->ID);
            $attributes = $variation->get_variation_attributes();
            // set preselected id to be used by JS to provide context
            $preselected_id = $single_product->post->ID;
            // get the parent product object
            $args = array('posts_per_page' => 1, 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'no_found_rows' => 1, 'p' => $single_product->post->post_parent);
            $single_product = new WP_Query($args);
            ?>
			<script type="text/javascript">
				jQuery( document ).ready( function( $ ) {
					var $variations_form = $( '[data-product-page-preselected-id="<?php 
            echo esc_attr($preselected_id);
            ?>
"]' ).find( 'form.variations_form' );

					<?php 
            foreach ($attributes as $attr => $value) {
                ?>
						$variations_form.find( 'select[name="<?php 
                echo esc_attr($attr);
                ?>
"]' ).val( '<?php 
                echo $value;
                ?>
' );
					<?php 
            }
            ?>
				});
			</script>
		<?php 
        }
        ob_start();
        while ($single_product->have_posts()) {
            $single_product->the_post();
            wp_enqueue_script('wc-single-product');
            ?>

			<div class="single-product" data-product-page-preselected-id="<?php 
            echo esc_attr($preselected_id);
            ?>
">

				<?php 
            wc_get_template_part('content', 'single-product');
            ?>

			</div>

		<?php 
        }
        // end of the loop.
        wp_reset_postdata();
        return '<div class="woocommerce">' . ob_get_clean() . '</div>';
    }
Пример #28
0
									<h2><?php 
_e('Shop our products &amp; <strong>Help us.</strong>', 'charity');
?>
</h2>
								</header>
								<div class="row">
								
								<div class="col-md-9 product-detail">

		<?php 
while (have_posts()) {
    the_post();
    ?>

			<?php 
    wc_get_template_part('content', 'single-product');
    ?>

		<?php 
}
// end of the loop.
?>

	</div>
<div class="col-md-3">
	<?php 
/**
 * woocommerce_sidebar hook
 *
 * @hooked woocommerce_get_sidebar - 10
 */
Пример #29
0
			
			<?php 
    woocommerce_product_loop_start();
    ?>

				<?php 
    woocommerce_product_subcategories();
    ?>

				<?php 
    while (have_posts()) {
        the_post();
        ?>

					<?php 
        wc_get_template_part('content', 'product');
        ?>

				<?php 
    }
    // end of the loop.
    ?>

			<?php 
    woocommerce_product_loop_end();
    ?>

			<?php 
    /**
     * woocommerce_after_shop_loop hook
     *
/**
 * @deprecated
 */
function woocommerce_get_template_part($slug, $name = '')
{
    wc_get_template_part($slug, $name);
}