function output_featured_products()
    {
        $args = array('post_type' => 'product', 'posts_per_page' => 3, 'product_tag' => 'featured', 'orderby' => 'rand');
        $products = new WP_Query($args);
        if ($products->have_posts()) {
            ?>
		<div class="related products">
			<h2><?php 
            _e('Featured Products', 'woocommerce');
            ?>
</h2>
			<?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();
            ?>
		</div>
	<?php 
        }
        wp_reset_postdata();
    }
Example #2
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>';
 }
Example #3
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;
 }
Example #4
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>';
}
 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>';
 }
Example #6
0
        function wr_ferado_product_slider($atts, $content = null)
        {
            $limit = $orderby = $order = $single = $class = $effect_output = '';
            extract(shortcode_atts(array('limit' => '10', 'orderby' => 'date', 'order' => 'desc', 'pagination' => 'false', 'navigation' => 'false', 'item' => 6, 'single' => 'false', 'cat' => '', 'title' => '', 'full' => '', 'effect' => ''), $atts));
            global $product, $woocommerce_loop, $post;
            // The meta query for the page
            $meta_query = WC()->query->get_meta_query();
            // Generate random id
            $length = 10;
            $id = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
            // Filter product post type
            $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $orderby, 'order' => $order, 'meta_query' => $meta_query, 'posts_per_page' => $limit);
            if (!empty($cat)) {
                $args['tax_query'] = array('relation' => 'AND', array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => explode(',', $cat)));
            }
            if ($effect) {
                $effect_output = '
					beforeMove: updateCarousel,
					afterInit: function() {
						setTimeout(updateCarousel, 100)
					}';
            }
            ob_start();
            $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
            echo '
				<scr' . 'ipt>
					(function($) {
						"use strict";
						$(document).ready(function() {
							var owl = $("#' . $id . '");
							owl.owlCarousel({
								navigation: ' . $navigation . ',
								navigationText: [
									"<i class=\\"dashicons dashicons-arrow-left-alt2\\"></i>",
									"<i class=\\"dashicons dashicons-arrow-right-alt2\\"></i>",
								],
								pagination: ' . $pagination . ',
								singleItem: ' . $single . ',
								items: ' . $item . ',
								itemsMobile : [540,1],
								itemsTablet : [768,2],
								itemsDesktopSmall : [1366,4],
								itemsDesktop: [1920,6],
								slideSpeed : 600,
								' . $effect_output . '
							});
							function updateCarousel() {
								var start = data.currentItem;
								var count = data.options.items;

								if ( window.innerWidth < 1921 ) {
									var endStart = start+count-1;
									var first2 = owl.find(".owl-item").slice(start,start+1);
									var last2 = owl.find(".owl-item").slice(endStart, endStart+1);
								} else {
									var endStart = start+count-2;
									var first2 = owl.find(".owl-item").slice(start,start+2);
									var last2 = owl.find(".owl-item").slice(endStart, endStart+2);
								}

								owl.find(".owl-item").removeClass("blur");
								first2.addClass("blur");
								last2.addClass("blur");

							}
							var data = owl.data("owlCarousel");
						});
					})(jQuery);
				</scr' . 'ipt>';
            if ('true' == $single) {
                $class .= 'single-gal';
            }
            if ('true' != $single && $title) {
                echo '<div class="h-slider"><h4 class="slider-title">' . $title . '</h4></div>';
            }
            // Begin the loop
            if ($products->have_posts()) {
                if (function_exists('woocommerce_product_loop_start')) {
                    woocommerce_product_loop_start();
                }
                ?>
				<div id="<?php 
                echo $id;
                ?>
" class="owl-carousel <?php 
                echo $class;
                ?>
">

					<?php 
                while ($products->have_posts()) {
                    $products->the_post();
                    global $product;
                    $cat_count = sizeof(get_the_terms($post->ID, 'product_cat'));
                    $tag_count = sizeof(get_the_terms($post->ID, 'product_tag'));
                    ?>
							<li <?php 
                    post_class();
                    ?>
>

								<div class="p-inner">

									<div class="p-grid">
										<span class="p-image">
											<?php 
                    if (class_exists('YITH_WCWL_UI')) {
                        echo wr_ferado_wishlist_button();
                    }
                    do_action('woocommerce_before_shop_loop_item_title');
                    ?>
											<div class="p-mask">
												<h3><a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h3>
												<?php 
                    woocommerce_get_template('loop/rating.php');
                    ?>
												<span class="p-desc">
													<?php 
                    if (!apply_filters('woocommerce_short_description', $post->post_excerpt)) {
                        $content = $post->post_content;
                        echo wp_trim_words(wpautop($content), 15);
                    } else {
                        echo wp_trim_words(apply_filters('woocommerce_short_description', $post->post_excerpt), 15);
                    }
                    ?>
												</span>
												<?php 
                    if (wc_product_sku_enabled() && ($product->get_sku() || $product->is_type('variable'))) {
                        ?>
													<span class="sku_wrapper"><?php 
                        _e('SKU:', 'woocommerce');
                        ?>
 <span class="sku" itemprop="sku"><?php 
                        echo ($sku = $product->get_sku()) ? $sku : __('N/A', 'woocommerce');
                        ?>
</span>.</span>
												<?php 
                    }
                    ?>
													<?php 
                    echo $product->get_categories(', ', '<span class="posted_in">' . _n('Category:', 'Categories:', $cat_count, 'woocommerce') . ' ', '.</span>');
                    ?>
												<?php 
                    echo $product->get_tags(', ', '<span class="tagged_as">' . _n('Tag:', 'Tags:', $tag_count, 'woocommerce') . ' ', '.</span>');
                    ?>
											</div>
										</span>
										<span class="p-info">
											<div class="p-cart">
												<?php 
                    woocommerce_get_template('loop/add-to-cart.php');
                    ?>
											</div>
											<?php 
                    do_action('woocommerce_after_shop_loop_item_title');
                    ?>
										</span>
									</div>
								</div>
							</li>
							<?php 
                }
                ?>

				</div>

				<?php 
                if (function_exists('woocommerce_product_loop_end')) {
                    woocommerce_product_loop_end();
                }
            }
            // Restore original Post Data
            wp_reset_postdata();
            return '<div class="woocommerce product-slider">' . ob_get_clean() . '</div>';
        }
    /**
     * Output shortcode
     *
     * @access public
     * @param array $atts
     * @return void
     * 
     */
    public static function output($atts)
    {
        global $woocommerce, $wpdb;
        extract(shortcode_atts(array('show_buy_it_now' => 'false'), $atts));
        if (!is_user_logged_in()) {
            return;
        }
        $user_id = get_current_user_id();
        $postids = array();
        $userauction = $wpdb->get_results("SELECT DISTINCT auction_id FROM " . $wpdb->prefix . "simple_auction_log WHERE userid = {$user_id} ", ARRAY_N);
        if (isset($userauction) && !empty($userauction)) {
            foreach ($userauction as $auction) {
                $postids[] = $auction[0];
            }
        }
        ?>
			<div class="simple-auctions active-auctions clearfix">
				<h2><?php 
        _e('Active auctions', 'wc_simple_auctions');
        ?>
</h2>
				
				<?php 
        $args = array('post__in' => $postids, 'post_type' => 'product', 'posts_per_page' => '-1', 'order' => 'ASC', 'orderby' => 'meta_value', 'tax_query' => array(array('taxonomy' => 'product_type', 'field' => 'slug', 'terms' => 'auction')), 'meta_query' => array(array('key' => '_auction_closed', 'compare' => 'NOT EXISTS')), 'auction_arhive' => TRUE, 'show_past_auctions' => FALSE);
        //var_dump($args);
        $activeloop = new WP_Query($args);
        //var_dump($activeloop);
        if ($activeloop->have_posts() && !empty($postids)) {
            woocommerce_product_loop_start();
            while ($activeloop->have_posts()) {
                $activeloop->the_post();
                woocommerce_get_template_part('content', 'product');
            }
            woocommerce_product_loop_end();
        } else {
            _e("You are not participating in auction.", "wc_simple_auctions");
        }
        wp_reset_postdata();
        ?>
			
			</div>
			<div class="simple-auctions active-auctions clearfix">
				<h2><?php 
        _e('Won auctions', 'wc_simple_auctions');
        ?>
</h2>
				
				<?php 
        $auction_closed_type[] = '2';
        if ($show_buy_it_now == 'true') {
            $auction_closed_type[] = '3';
        }
        $args = array('post_type' => 'product', 'posts_per_page' => '-1', 'order' => 'ASC', 'orderby' => 'meta_value', 'meta_key' => '_auction_dates_to', 'meta_query' => array(array('key' => '_auction_closed', 'value' => $auction_closed_type, 'compare' => 'IN'), array('key' => '_auction_current_bider', 'value' => $user_id)), 'show_past_auctions' => TRUE, 'auction_arhive' => TRUE);
        $winningloop = new WP_Query($args);
        if ($winningloop->have_posts() && !empty($postids)) {
            woocommerce_product_loop_start();
            while ($winningloop->have_posts()) {
                $winningloop->the_post();
                woocommerce_get_template_part('content', 'product');
            }
            woocommerce_product_loop_end();
        } else {
            _e("You did not win any auctions yet.", "wc_simple_auctions");
        }
        wp_reset_postdata();
        echo "</div>";
    }
 /**
  * Loop over found products.
  *
  * @since  1.0.0
  * @param  array $query_args \WP_Query arguments.
  * @param  array $atts       User defined attributes in shortcode tag.
  * @return string            Current buffer contents.
  */
 private function get_products($query_args, $atts)
 {
     global $woocommerce_loop;
     $category = \sanitize_title($atts['category']);
     $taxonomy = \sanitize_text_field($atts['taxonomy']);
     $columns = absint($atts['columns']);
     $woocommerce_loop['columns'] = $columns;
     $products = new \WP_Query($query_args);
     ob_start();
     if ($products->have_posts()) {
         \do_action('woocommerce_shortcode_before_featured_products_by_category', $category, $taxonomy);
         \woocommerce_product_loop_start();
         while ($products->have_posts()) {
             $products->the_post();
             \wc_get_template_part('content', 'product');
         }
         \woocommerce_product_loop_end();
         \do_action('woocommerce_shortcode_after_featured_products_by_category', $category, $taxonomy);
     }
     \woocommerce_reset_loop();
     \wp_reset_postdata();
     return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
 }
Example #9
0
        function fruitful_woocommerce_cross_sell_display()
        {
            if (!defined('ABSPATH')) {
                exit;
            }
            // Exit if accessed directly
            global $woocommerce_loop, $woocommerce, $product;
            $crosssells = $woocommerce->cart->get_cross_sells();
            if (sizeof($crosssells) == 0) {
                return;
            }
            $meta_query = $woocommerce->query->get_meta_query();
            $args = array('post_type' => 'product', 'ignore_sticky_posts' => 1, 'posts_per_page' => apply_filters('woocommerce_cross_sells_total', 4), 'no_found_rows' => 1, 'orderby' => 'rand', 'post__in' => $crosssells, 'meta_query' => $meta_query);
            $products = new WP_Query($args);
            $woocommerce_loop['columns'] = apply_filters('woocommerce_cross_sells_columns', 4);
            if ($products->have_posts()) {
                ?>
				<div class="cross-sells">
					<h2><?php 
                _e('You may be interested in&hellip;', 'woocommerce');
                ?>
</h2>
					<?php 
                woocommerce_product_loop_start();
                ?>
						<?php 
                while ($products->have_posts()) {
                    $products->the_post();
                    ?>
							<?php 
                    woocommerce_get_template_part('content', 'product');
                    ?>
						<?php 
                }
                // end of the loop.
                ?>
					<?php 
                woocommerce_product_loop_end();
                ?>
				</div>
			<?php 
            }
            wp_reset_query();
        }
Example #10
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();
    }
 public static function do_action_output_related_products($initargs)
 {
     global $product, $woocommerce_loop, $pwyw_related_product;
     $show_related = get_option(self::ID . '_show_related_products');
     if ($show_related == 'yes' || $show_related == '1') {
         $pwyw_related_product = true;
         $posts_per_page = 2;
         $columns = $woocommerce_loop['columns'];
         if (!isset($columns)) {
             $columns = 2;
         }
         $orderby = 'rand';
         $related = $product->get_related($posts_per_page);
         if (sizeof($related) == 0) {
             return;
         }
         $args = apply_filters('woocommerce_related_products_args', array('post_type' => 'product', 'pwyw_type' => 'related', 'ignore_sticky_posts' => 1, 'no_found_rows' => 1, 'posts_per_page' => $posts_per_page, 'orderby' => $orderby, 'post__in' => $related, 'post__not_in' => array($product->id)));
         $products = new WP_Query($args);
         $woocommerce_loop['columns'] = $columns;
         if ($products->have_posts()) {
             echo '<div class="related products">';
             echo '    <h2>' . __('Related Products', 'woocomerce') . '</h2>';
             woocommerce_product_loop_start();
             echo "    <ul>";
             while ($products->have_posts()) {
                 $products->the_post();
                 wc_get_template_part('content', 'product');
             }
             echo "    </ul>";
             woocommerce_product_loop_end();
             echo '</div>';
         }
         wp_reset_postdata();
         $pwyw_related_product = false;
     }
 }
Example #12
0
    public function woof_products($atts)
    {
        $_REQUEST['woof_products_doing'] = 1;
        //add_filter('posts_where', array($this, 'woof_post_text_filter'), 9999);
        //add_filter('posts_where', array($this, 'woof_post_author_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'] : '');
        //https://gist.github.com/mikejolley/1622323
        extract(shortcode_atts(array('columns' => apply_filters('loop_shop_columns', 4), 'orderby' => 'no', 'order' => 'no', 'page' => 1, 'per_page' => 0, 'is_ajax' => 0, 'taxonomies' => '', 'sid' => '', 'dp' => 0, 'behavior' => ''), $atts));
        $order_by_defined_in_atts = false;
        if ($orderby == 'no') {
            $orderby = $catalog_orderby['orderby'];
            $order = $catalog_orderby['order'];
        } else {
            $order_by_defined_in_atts = true;
        }
        //***
        //this needs just for AJAX mode for shortcode [woof] in woof_draw_products()
        $_REQUEST['woof_additional_taxonomies_string'] = $taxonomies;
        //+++
        $args = array('post_type' => array('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 (!$order_by_defined_in_atts) {
            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;
        }
        //+++
        if (!empty($behavior)) {
            switch ($behavior) {
                case 'recent':
                    $args['orderby'] = 'date';
                    $args['order'] = 'desc';
                    break;
                default:
                    break;
            }
        }
        //***
        $wr = apply_filters('woocommerce_shortcode_products_query', $args, $atts);
        global $products, $wp_query;
        $wr = apply_filters('woof_products_query', $wr);
        //print_r($wr);
        $_REQUEST['woof_wp_query'] = $wp_query = $products = new WP_Query($wr);
        if ($this->get_option('listen_catalog_visibility') and $this->is_isset_in_request_data($this->get_swoof_search_slug())) {
            //for wp-content\plugins\woocommerce\includes\class-wc-query.php -> $in = array( 'visible', 'search' )
            $wp_query->is_search = true;
        }
        $wp_query->is_post_type_archive = true;
        //we need it to display top panel with counter and order drop-down
        $_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 
            $show_loop_filters = true;
            //for attribute behavior of the shortcode
            if (!empty($behavior)) {
                if ($behavior == 'recent') {
                    $show_loop_filters = false;
                }
            }
            if ($dp == 0) {
                //Display Product for WooCommerce compatibility
                if ($show_loop_filters) {
                    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');
            ?>



                    <?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 
            if ($show_loop_filters) {
                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();
    }
    /**
     * Display a single product.
     *
     * @param array $atts
     * @return string
     */
    public static function product($atts)
    {
        if (empty($atts)) {
            return '';
        }
        $meta_query = WC()->query->get_meta_query();
        $args = array('post_type' => 'product', 'posts_per_page' => 1, 'no_found_rows' => 1, 'post_status' => 'publish', 'meta_query' => $meta_query);
        if (isset($atts['sku'])) {
            $args['meta_query'][] = array('key' => '_sku', 'value' => $atts['sku'], 'compare' => '=');
        }
        if (isset($atts['id'])) {
            $args['p'] = $atts['id'];
        }
        ob_start();
        $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
        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();
        $css_class = 'woocommerce';
        if (isset($atts['class'])) {
            $css_class .= ' ' . $atts['class'];
        }
        return '<div class="' . esc_attr($css_class) . '">' . ob_get_clean() . '</div>';
    }
/**
 * 
 * @global type $woocommerce
 * @global type $post
 */
function zwt_woocommerce_customer_also_viewed($atts, $content = null)
{
    $per_page = get_option('total_items_display');
    $plugin_title = get_option('customer_who_viewed_title');
    $category_filter = get_option('category_filter');
    $show_image_filter = get_option('show_image_filter');
    $show_price_filter = get_option('show_price_filter');
    $show_addtocart_filter = get_option('show_addtocart_filter');
    $product_order = get_option('product_order');
    // Get WooCommerce Global
    global $woocommerce;
    global $post;
    // Get recently viewed product data using get_option
    $customer_also_viewed = get_option('customer_also_viewed_' . $post->ID);
    if (!empty($customer_also_viewed)) {
        $customer_also_viewed = explode(',', $customer_also_viewed);
        $customer_also_viewed = array_reverse($customer_also_viewed);
        //Skip same product on product page from the list
        if (($key = array_search($post->ID, $customer_also_viewed)) !== false) {
            unset($customer_also_viewed[$key]);
        }
        $per_page = $per_page == "" ? $per_page = 5 : $per_page;
        $plugin_title = $plugin_title == "" ? $plugin_title = 'Customer Who Viewed This Item Also Viewed' : $plugin_title;
        // Create the object
        ob_start();
        $categories = get_the_terms($post->ID, 'product_cat');
        // Create query arguments array
        $query_args = array('posts_per_page' => $per_page, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $customer_also_viewed);
        $query_args['orderby'] = $product_order == '' ? 'ID(ID, explode(' . $customer_also_viewed . '))' : $product_order;
        //Executes if category filter applied on product page
        if ($category_filter == 1 && !empty($categories)) {
            foreach ($categories as $category) {
                if ($category->parent == 0) {
                    $category_slug = $category->slug;
                }
            }
            $query_args['product_cat'] = $category_slug;
        }
        // Add meta_query to query args
        $query_args['meta_query'] = array();
        // Check products stock status
        $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query();
        // Create a new query
        $products = new WP_Query($query_args);
        // If query return results
        if (!$products->have_posts()) {
            // If no data, quit
            exit;
        } else {
            //Displays title
            ?>
        
            <h2><?php 
            _e($plugin_title, 'woocommerce');
            ?>
</h2>
                <div class="clear">
                    <div class="woocommerce customer_also_viewed">                   
                        <?php 
            // Start the loop
            $count = 1;
            woocommerce_product_loop_start();
            while ($products->have_posts()) {
                $products->the_post();
                ?>
                             <li class="product">
                                 <?php 
                do_action('woocommerce_before_shop_loop_item');
                ?>
                                     <a href="<?php 
                the_permalink();
                ?>
">
                                         <?php 
                if ($show_image_filter == 1) {
                    do_action('woocommerce_before_shop_loop_item_title');
                }
                ?>
                                             <!--<h3><?php 
                /*the_title();; */
                ?>
</h3>-->
                                         <?php 
                if ($show_price_filter == 1) {
                    do_action('woocommerce_after_shop_loop_item_title');
                }
                ?>
                                     </a>
                                 <?php 
                if ($show_addtocart_filter == 1) {
                    do_action('woocommerce_after_shop_loop_item');
                }
                ?>
                        
                             </li>
                         <?php 
            }
            ?>
                         <?php 
            woocommerce_product_loop_end();
            ?>
                    </div>
                </div>
           <?php 
        }
        wp_reset_postdata();
    }
}
 protected function content($atts, $content = null)
 {
     $atts = shortcode_atts(array('title' => esc_html__('Title', 'js_composer'), 'source' => 'widgets', 'categories' => '', 'per_page' => 8, 'orderby' => 'date', 'order' => 'DESC', 'style' => 1, 'active_section' => 1, 'font_size' => '', 'line_height' => '', 'letter_spacing' => '', 'font_container' => '', 'use_theme_fonts' => 'yes', 'google_fonts' => '', 'css_animation' => '', 'el_class' => '', 'css' => '', 'operator' => 'IN'), $atts);
     $columns = 3;
     $product_type = 'classic';
     // This is needed to extract $font_container_data and $google_fonts_data
     extract($this->getAttributes($atts));
     unset($font_container_data['values']['text_align']);
     $atts = vc_map_get_attributes($this->getShortcode(), $atts);
     extract($atts);
     extract($this->getStyles($el_class, $css, $google_fonts_data, $font_container_data, $atts));
     $settings = get_option('wpb_js_google_fonts_subsets');
     if (is_array($settings) && !empty($settings)) {
         $subsets = '&subset=' . implode(',', $settings);
     } else {
         $subsets = '';
     }
     if (isset($google_fonts_data['values']['font_family'])) {
         wp_enqueue_style('vc_google_fonts_' . vc_build_safe_css_class($google_fonts_data['values']['font_family']), '//fonts.googleapis.com/css?family=' . $google_fonts_data['values']['font_family'] . $subsets);
     }
     if ($letter_spacing) {
         if (empty($styles)) {
             $styles = array();
         }
         $styles[] = 'letter-spacing: ' . $letter_spacing . 'px';
     }
     if (!empty($styles)) {
         $style = 'style="' . esc_attr(implode(';', $styles)) . '"';
     } else {
         $style = '';
     }
     $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'wc-products-vertical', $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 cruxstore-products-classic', 'woocommerce' => 'woocommerce columns-' . $columns);
     if (!$active_section) {
         $active_section = 1;
     }
     $uniqeID = uniqid();
     $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'], 'meta_query' => $meta_query);
     if ($source == 'categories') {
         $tabs = explode(',', $categories);
         $args['order'] = $order;
         $args['orderby'] = $orderby;
     } else {
         $tabs = array('onsale', 'new', 'bestselling');
     }
     $tab_heading = '<ul class="nav-style" data-count="' . count($tabs) . '">';
     $i = 1;
     foreach ($tabs as $tab) {
         if ($source == 'categories') {
             $term = get_term_by('slug', sanitize_title($tab), 'product_cat');
             $text = $term->name;
         } else {
             if ($tab == 'new') {
                 $text = esc_html__('Arrivals Products', 'cruxstore');
             } elseif ($tab == 'bestselling') {
                 $text = esc_html__('Best Sellers', 'cruxstore');
             } elseif ($tab == 'onsale') {
                 $text = esc_html__('On sale', 'cruxstore');
             }
         }
         $class = $active_section == $i ? ' class="active"' : '';
         $tab_heading .= sprintf('<li %s><a href="%s" data-toggle="tab"><span data-hover="%s">%s</span></a></li>', $class, '#tab-' . $tab . '-' . $uniqeID, esc_attr($text), $text);
         $i++;
     }
     $tab_heading .= "</ul>";
     global $woocommerce_loop;
     $i = 1;
     $output_content = '';
     $carousel_atts = array('desktop' => $columns, 'navigation' => false, 'gutters' => false);
     $carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $carousel_atts), '', 'wc-carousel-wrapper');
     foreach ($tabs as $tab) {
         $new_args = $args;
         if ($source == 'categories') {
             $new_args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => sanitize_title($tab), 'field' => 'slug', 'operator' => $atts['operator']));
         } else {
             if ($tab == 'bestselling') {
                 $new_args['meta_key'] = 'total_sales';
                 $new_args['orderby'] = 'meta_value_num';
             } elseif ($tab == 'featured') {
                 $new_args['meta_query'][] = array('key' => '_featured', 'value' => 'yes');
             } elseif ($tab == 'onsale') {
                 $new_args['post__in'] = array_merge(array(0), wc_get_product_ids_on_sale());
             }
         }
         $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $new_args, $atts));
         $woocommerce_loop['columns'] = $columns;
         $woocommerce_loop['type'] = $product_type;
         ob_start();
         if ($products->have_posts()) {
             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();
         }
         wp_reset_postdata();
         $carousel_html = ob_get_clean();
         $carousel_html = str_replace('%carousel_html%', $carousel_html, $carousel_ouput);
         $class = $active_section == $i ? 'fade in active' : 'fade';
         $output_content .= sprintf('<div id="%s" class="tab-pane %s">%s</div><!-- .tab-pane -->', 'tab-' . $tab . '-' . $uniqeID, $class, $carousel_html);
         $i++;
     }
     $custom_css = '';
     $rand = 'wc-products-vertical-' . rand();
     if ($font_size) {
         $custom_css .= cruxstore_responsive_render('#' . $rand . ' .wc-products-vertical-title', 'font-size', $font_size);
     }
     if ($line_height) {
         $custom_css .= cruxstore_responsive_render('#' . $rand . ' .wc-products-vertical-title', 'line-height', $line_height);
     }
     $title = sprintf('<%1$s class="wc-products-vertical-title" %2$s>%3$s</%1$s>', $font_container_data['values']['tag'], $style, $title);
     $heading = sprintf('<div class="wc-products-vertical-heading">%s</div>', $tab_heading);
     $navigation = '<div class="wc-products-vertical-navigation"><span class="wc-products-vertical-left"><i class="fa fa-angle-left" aria-hidden="true"></i></span><span class="wc-products-vertical-right"><i class="fa fa-angle-right" aria-hidden="true"></i></span></div>';
     $content = $content ? sprintf('<div class="wc-products-vertical-content">%s</div>', $content) : '';
     $output = sprintf('<div class="row"><div class="col-md-3">%s</div><div class="col-md-9"><div class="tab-content">%s</div></div></div>', $title . $content . $heading . $navigation, $output_content);
     if ($custom_css) {
         $custom_css = '<div class="cruxstore_custom_css" data-css="' . esc_attr($custom_css) . '"></div>';
     }
     $output .= $custom_css;
     $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass));
     $output = '<div id="' . $rand . '" class="' . esc_attr($elementClass) . '">' . $output . '</div>';
     return $output;
 }
    /**
     * 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.
     *
     */
    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 
                do_action('woocommerce_no_products_found');
                ?>

			<?php 
            }
        }
    }
Example #17
0
			/**
			* 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 using hooks or modifying core templates.
			*
			* @access public
			* @return void
			*
			* WM: OVERRIDE
			* Just removed H1 tag
			*/
			function woocommerce_content() {

				if ( is_singular( 'product' ) ) {

					while ( have_posts() ) : the_post();

						woocommerce_get_template_part( 'content', 'single-product' );

					endwhile;

				} else {

					//Just removed H1 tag

					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 woocommerce_get_template_part( 'content', 'product' ); ?>

							<?php endwhile; // 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 woocommerce_get_template( 'loop/no-products-found.php' ); ?>

					<?php endif;

				}
			} // /woocommerce_content
Example #18
0
    function etheme_products($args, $title = false, $columns = 4)
    {
        global $wpdb, $woocommerce_loop;
        ob_start();
        $products = new WP_Query($args);
        $class = $title_output = '';
        $shop_url = get_permalink(woocommerce_get_page_id('shop'));
        if ($title != '') {
            $title_output = '<h2 class="title"><span>' . $title . '</span></h2>';
        }
        $woocommerce_loop['columns'] = $columns;
        if ($products->have_posts()) {
            echo $title_output;
            ?>
            <?php 
            woocommerce_product_loop_start();
            ?>

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

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

                <?php 
            }
            // end of the loop.
            ?>
                
            <?php 
            woocommerce_product_loop_end();
            ?>

        <?php 
        }
        wp_reset_postdata();
        return '<div class="woocommerce">' . ob_get_clean() . '</div>';
    }
Example #19
0
function pw_woo_ad_search_action_build_query_sql_result()
{
    global $wpdb, $pw_woo_ad_main_class;
    $return_value = $pw_woo_ad_main_class->build_search_query($_POST);
    $post = new WP_Query($return_value['query']);
    //PAGINATION OPTIONS
    $all_page_number = $post->max_num_pages;
    extract($_POST);
    //print_r($_POST);
    $pw_sf_pagination_type = isset($_POST['pw_sf_pagination_type']) ? $_POST['pw_sf_pagination_type'] : 'pagination_no';
    $pw_sf_pagination_paged = isset($_POST['pw_sf_pagination_paged']) ? $_POST['pw_sf_pagination_paged'] : '1';
    $pw_sf_part = isset($_POST['pw_sf_part']) ? $_POST['pw_sf_part'] : '';
    switch ($pw_sf_part) {
        case "pw_woo_ad_grid_search":
            $my_query = new WP_Query($return_value['query']);
            //print_r($return_value['query']);
            //echo $my_query->request;
            $pw_woo_ad_main_class->fetch_custom_fields($pw_sf_shortcode_id);
            $shortcode_id = $pw_sf_shortcode_id;
            if ($my_query->have_posts()) {
                require __PW_ROOT_WOO_AD_SEARCH__ . '/frontend/content-product.php';
            } else {
                echo $pw_woo_ad_main_class->alert('error', __('No results were found. Please try a different search!', __PW_WOO_AD_SEARCH_TEXTDOMAIN__));
            }
            require 'actions_pagination.php';
            echo $pagination;
            break;
        case "pw_woo_ad_grid":
            $my_query = new WP_Query($return_value['query']);
            //echo $my_query->request;
            $pw_woo_ad_main_class->fetch_custom_fields($pw_sf_shortcode_id);
            $shortcode_id = $pw_sf_shortcode_id;
            if ($my_query->have_posts()) {
                require __PW_ROOT_WOO_AD_SEARCH__ . '/frontend/content-product.php';
            } else {
                echo $pw_woo_ad_main_class->alert('error', __('No results were found. Please try a different search!', __PW_WOO_AD_SEARCH_TEXTDOMAIN__));
            }
            require 'actions_pagination.php';
            echo $pagination;
            break;
        case "pw_woo_ad_grid_archive_page":
            $products = new WP_Query($return_value['query']);
            $woocommerce_loop['columns'] = 4;
            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();
            echo '<div class="woocommerce columns-4">' . ob_get_clean() . '</div>';
            break;
    }
    echo '@' . implode(' ', $return_value['your_search']);
    exit(0);
}
Example #20
0
function avada_woo_product($atts, $content = null)
{
    global $woocommerce_loop;
    if (empty($atts)) {
        return;
    }
    $args = array('post_type' => 'product', 'posts_per_page' => 1, 'no_found_rows' => 1, 'post_status' => 'publish', 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')), 'columns' => 1);
    if (isset($atts['sku'])) {
        $args['meta_query'][] = array('key' => '_sku', 'value' => $atts['sku'], 'compare' => '=');
    }
    if (isset($atts['id'])) {
        $args['p'] = $atts['id'];
    }
    ob_start();
    if (isset($columns)) {
        $woocommerce_loop['columns'] = $columns;
    }
    $products = new WP_Query($args);
    if ($products->have_posts()) {
        ?>

		<?php 
        woocommerce_product_loop_start();
        ?>

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

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

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

		<?php 
        woocommerce_product_loop_end();
        ?>

	<?php 
    }
    wp_reset_postdata();
    return '<div class="woocommerce">' . ob_get_clean() . '</div>';
}
Example #21
0
    function anaglyph_woo_get_loop_shop_content()
    {
        global $anaglyph_config, $time_post_delay;
        $layout = 1;
        $class_content = 'col-md-12';
        $layout = esc_attr($anaglyph_config['shop-layout']);
        if ($layout > 1) {
            $class_content = 'col-md-9';
        }
        ?>
		<?php 
        /**
         * woocommerce_before_main_content hook
         *
         * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
         * @hooked woocommerce_breadcrumb - 20
         */
        do_action('woocommerce_before_main_content');
        do_action('woocommerce_archive_description');
        ?>
		<div class="<?php 
        echo $class_content;
        ?>
">	
	
		<?php 
        if (have_posts()) {
            ?>
			<?php 
            /**
             * woocommerce_before_shop_loop hook
             *
             * @hooked woocommerce_result_count - 20
             * @hooked woocommerce_catalog_ordering - 30
             */
            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 
                $time_post_delay += 0.2;
                ?>
				<?php 
            }
            // end of the loop.
            ?>
			<?php 
            woocommerce_product_loop_end();
            ?>
			
			<?php 
            /**
             * woocommerce_after_shop_loop hook
             *
             * @hooked woocommerce_pagination - 10
             */
            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 
        }
        ?>
		</div> <!-- end products loop content -->
		
		
		<?php 
        /**
         * woocommerce_after_main_content hook
         *
         * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
         */
        do_action('woocommerce_after_main_content');
    }
Example #22
0
function miss_woocommerce_content()
{
    if (is_singular('product')) {
        while (have_posts()) {
            the_post();
            woocommerce_get_template_part('content', 'single-product');
        }
    } else {
        ?>

		<?php 
        if (apply_filters('woocommerce_show_page_title', true)) {
            ?>
            <div class="bread-container">
                <div class="bread-wrapper">
                    <div class="blog-title"><?php 
            woocommerce_page_title();
            ?>
</div>
                    <?php 
            dimox_breadcrumbs();
            ?>
                </div>
            </div>

		<?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 
                woocommerce_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 
            woocommerce_get_template('loop/no-products-found.php');
            ?>

		<?php 
        }
    }
}
Example #23
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>';
    }
Example #24
0
function woo_products_by_attributes_shortcode($atts, $content = null)
{
    global $woocommerce, $woocommerce_loop;
    // Get attribuets
    extract(shortcode_atts(array('attribute' => '', 'values' => '', 'per_page' => '12', 'columns' => '4', 'orderby' => 'title', 'order' => 'desc'), $atts));
    if (!$attribute) {
        return;
    }
    // Default ordering args
    $ordering_args = $woocommerce->query->get_catalog_ordering_args($orderby, $order);
    // Define Query Arguments
    $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $ordering_args['orderby'], 'order' => $ordering_args['order'], 'posts_per_page' => $per_page, 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')), 'tax_query' => array(array('taxonomy' => 'pa_' . $attribute, 'terms' => explode(",", $values), 'field' => 'slug', 'operator' => 'IN')));
    ob_start();
    $products = new WP_Query($args);
    $woocommerce_loop['columns'] = $columns;
    if ($products->have_posts()) {
        ?>
		 
		<?php 
        woocommerce_product_loop_start();
        ?>
		 
		<?php 
        while ($products->have_posts()) {
            $products->the_post();
            ?>
		 
		<?php 
            woocommerce_get_template_part('content', 'product');
            ?>
		 
		<?php 
        }
        // end of the loop.
        ?>
		 
		<?php 
        woocommerce_product_loop_end();
        ?>
		 
		<?php 
    }
    wp_reset_postdata();
    return '<div class="woocommerce">' . ob_get_clean() . '</div>';
}
Example #25
0
 public function product_lookbook_shortcode($atts, $content = null)
 {
     global $woocommerce_loop;
     $atts = shortcode_atts(array('number' => null, 'orderby' => 'name', 'order' => 'ASC', 'columns' => '4', 'hide_empty' => 1, 'parent' => '', 'ids' => ''), $atts);
     if (isset($atts['ids'])) {
         $ids = explode(',', $atts['ids']);
         $ids = array_map('trim', $ids);
     } else {
         $ids = array();
     }
     $hide_empty = $atts['hide_empty'] == true || $atts['hide_empty'] == 1 ? 1 : 0;
     // get terms and workaround WP bug with parents/pad counts
     $args = array('orderby' => $atts['orderby'], 'order' => $atts['order'], 'hide_empty' => $hide_empty, 'include' => $ids, 'pad_counts' => true, 'child_of' => $atts['parent']);
     $product_brands = get_terms('product_brand', $args);
     if ('' !== $atts['parent']) {
         $product_brands = wp_list_filter($product_brands, array('parent' => $atts['parent']));
     }
     if ($hide_empty) {
         foreach ($product_brands as $key => $brand) {
             if ($brand->count == 0) {
                 unset($product_brands[$key]);
             }
         }
     }
     if ($atts['number']) {
         $product_brands = array_slice($product_brands, 0, $atts['number']);
     }
     $woocommerce_loop['columns'] = $atts['columns'];
     ob_start();
     // Reset loop/columns globals when starting a new loop
     $woocommerce_loop['loop'] = $woocommerce_loop['column'] = '';
     if ($product_brands) {
         woocommerce_product_loop_start();
         foreach ($product_brands as $brand) {
             wc_get_template('content-product_brand.php', array('brand' => $brand));
         }
         woocommerce_product_loop_end();
     }
     woocommerce_reset_loop();
     return '<div class="woocommerce columns-' . $atts['columns'] . '">' . ob_get_clean() . '</div>';
 }
Example #26
0
    function snpshpwp_products_category($atts, $content = null)
    {
        extract(shortcode_atts(array('ids' => '', 'rows' => 1, 'columns' => '4', 'orderby' => 'date', 'order' => 'DESC', 'meta_key' => '', 'ajax' => 'yes', 'pagination' => 'yes', 'bot_margin' => 36, 'class' => '', 'shortcode_id' => '', 'animate' => 'none', 'animation_delay' => 0, 'animation_group' => ''), $atts));
        if ($ids == '') {
            return __('Please select categories', 'snpshpwp');
        }
        $exploded = explode(',', $ids);
        global $paged;
        $args = array();
        if (empty($paged)) {
            $paged = 1;
        }
        if (isset($_GET['orderby'])) {
            if ($_GET['orderby'] == 'price' || $_GET['orderby'] == 'price-desc') {
                $orderby = 'meta_value_num';
                $order = $_GET['orderby'] == 'price' ? 'ASC' : 'DESC';
                $args = array('meta_key' => '_price');
            } else {
                if ($_GET['orderby'] == 'rating') {
                    add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses'));
                } else {
                    if ($_GET['orderby'] == 'popularity') {
                        $orderby = 'meta_value_num';
                        $order = 'DESC';
                        $args = array('meta_key' => 'total_sales');
                    } else {
                        if ($_GET['orderby'] == 'menu_order') {
                            $orderby = $orderby;
                        } else {
                            $orderby = $_GET['orderby'];
                        }
                    }
                }
            }
        }
        if (isset($_GET['min_price']) && isset($_GET['max_price'])) {
            $orderby = 'meta_value_num';
            $order = 'ASC';
            $args['meta_query'] = array(array('key' => '_price', 'value' => array(floatval($_GET['min_price']), floatval($_GET['max_price'])), 'type' => 'numeric', 'compare' => 'BETWEEN'));
        }
        if (isset($_GET['product_tag'])) {
            $args = array_merge($args, array('product_tag' => $_GET['product_tag']));
        }
        if (isset($_GET['characteristics'])) {
            $args = array_merge($args, array('characteristics' => $_GET['characteristics']));
        }
        if (isset($_GET['sale_products'])) {
            $meta_query = array(array('key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric'));
            $args['meta_query'] = $meta_query;
        }
        if (isset($_GET['product_cat'])) {
            $args = $args + array('tax_query' => array(array('taxonomy' => 'product_cat', 'terms' => array($_GET['product_cat']), 'field' => 'slug', 'operator' => 'IN')));
        } else {
            if ($ids !== '0') {
                $args = $args + array('tax_query' => array(array('taxonomy' => 'product_cat', 'terms' => $exploded, 'field' => 'slug', 'operator' => 'IN')));
            }
        }
        foreach ($_GET as $k => $v) {
            if (strpos($k, 'pa_') !== false) {
                $args = $args + array('tax_query' => array(array('taxonomy' => $k, 'terms' => $v, 'field' => 'slug', 'operator' => 'IN')));
            }
        }
        if (!isset($args['meta_query'])) {
            $args['meta_query'] = WC()->query->get_meta_query();
        }
        $args = $args + array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => $columns * $rows, 'paged' => $paged, 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')));
        if (!isset($args['meta_query'])) {
            $args['meta_query'] = WC()->query->get_meta_query();
        }
        $query_string_ajax = http_build_query($args);
        $bot_margin = (int) $bot_margin;
        $margin = " style='margin-bottom" . $bot_margin . "px'";
        $out = '';
        $html_pag = '';
        global $woocommerce, $woocommerce_loop;
        $woocommerce_loop['columns'] = $columns;
        $products = new WP_Query($args);
        if ($pagination == 'true') {
            $html_pag = snpshpwp_mini_woo_pagination($products->max_num_pages, $paged, 3, $ajax);
        }
        ob_start();
        if ($products->have_posts()) {
            ?>

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

		<?php 
            woocommerce_product_loop_start();
            ?>

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

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

			<?php 
            }
            ?>

		<?php 
            woocommerce_product_loop_end();
            ?>

	<?php 
        }
        wp_reset_postdata();
        $shortcode = ob_get_clean();
        $out .= do_shortcode($shortcode) . $html_pag;
        if ($animate != 'none') {
            $animate = ' frb_animated frb_' . $animate . '"';
            if ($animation_delay != 0) {
                $animation_delay = (int) $animation_delay;
                $animate .= ' data-adelay="' . $animation_delay . '"';
            }
            if ($animation_group != '') {
                $animate .= ' data-agroup="' . $animation_group . '"';
            }
        } else {
            $animate = '"';
        }
        $html_animated = '<div ' . ($shortcode_id != '' ? 'id="' . $shortcode_id . '"' : '') . ' class="snpshpwp_woo_wrap div_touch_optimized snpshpwp_div_inherit_width ' . $class . $animate . ' style="padding-bottom:' . $bot_margin . 'px !important;" data-string="' . $query_string_ajax . '" data-shortcode="' . $margin . '|' . $columns . '|' . $pagination . '|' . $ajax . '">' . $out . '</div>';
        return $html_animated;
    }
Example #27
0
$args = array('post_type' => 'product', 'ignore_sticky_posts' => 1, 'posts_per_page' => apply_filters('woocommerce_cross_sells_total', 2), 'no_found_rows' => 1, 'orderby' => 'rand', 'post__in' => $crosssells, 'meta_query' => $meta_query);
$products = new WP_Query($args);
$woocommerce_loop['columns'] = apply_filters('woocommerce_cross_sells_columns', 2);
if ($products->have_posts()) {
    ?>


	<div class="cross-sells">

		<h2><?php 
    _e('You may be interested in&hellip;', 'woocommerce');
    ?>
</h2>

		<?php 
    woocommerce_product_loop_start();
    ?>


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


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


			<?php 
Example #28
0
    function wd_top_rated_product($atts, $content = null)
    {
        $_actived = apply_filters('active_plugins', get_option('active_plugins'));
        if (!in_array("woocommerce/woocommerce.php", $_actived)) {
            return;
        }
        global $woocommerce_loop, $woocommerce, $wd_data;
        extract(shortcode_atts(array('columns' => 4, 'per_page' => 4, 'cat_slug' => '', 'product_tag' => '', 'title' => '', 'desc' => '', 'show_type' => 'grid', 'show_image' => 1, 'show_title' => 1, 'show_sku' => 0, 'show_price' => 1, 'show_rating' => 1, 'show_label' => 1, 'show_categories' => 1, 'show_add_to_cart' => 1, 'show_short_content' => 0), $atts));
        if ($columns > 6) {
            $columns = 6;
        }
        if ($per_page < 1) {
            $per_page = 6;
        }
        if ($columns < 1) {
            $columns = 2;
        }
        if ($columns > 6) {
            $columns = 6;
        }
        $options = array('show_image' => $show_image, 'show_categories' => $show_categories, 'show_title' => $show_title, 'show_rating' => $show_rating, 'show_sku' => $show_sku, 'show_short_content' => $show_short_content, 'show_price' => $show_price, 'show_label' => $show_label, 'show_add_to_cart' => $show_add_to_cart);
        wd_remove_function_from_product_hook($options);
        $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'orderby' => 'date', 'order' => 'desc', 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')));
        if (trim($cat_slug) != '') {
            $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($cat_slug)), 'field' => 'slug', 'operator' => 'IN'));
        }
        if (strlen($product_tag) > 0 && strcmp('all-product-tags', $product_tag) != 0) {
            $args = array_merge($args, array('product_tag' => $product_tag));
        }
        ob_start();
        if (isset($wd_data['wd_prod_cat_column']) && absint($wd_data['wd_prod_cat_column']) > 0) {
            $_old_wd_prod_cat_column = $wd_data['wd_prod_cat_column'];
            $wd_data['wd_prod_cat_column'] = $columns;
        }
        $_old_woocommerce_loop_columns = $woocommerce_loop['columns'];
        add_filter('posts_clauses', 'wd_order_by_rating_post_clauses');
        $products = new WP_Query($args);
        remove_filter('posts_clauses', 'wd_order_by_rating_post_clauses');
        $woocommerce_loop['columns'] = $columns;
        $extra_class = '';
        if ($products->have_posts()) {
            ?>
				<div class="top-rated-product-sc shortcode-product <?php 
            echo $show_type;
            ?>
">
					<?php 
            if (strlen(trim($title)) > 0 || strlen(trim($desc)) > 0) {
                ?>
					<header class="shortcode-title-wrapper"> 
						<?php 
                if (strlen(trim($title)) > 0) {
                    echo "<h3 class='heading-title slider-title'>" . esc_html($title) . "</h3>";
                }
                ?>
					</header>
					<?php 
                if (strlen(trim($desc)) > 0) {
                    echo "<p class='slider-desc-wrapper'>" . esc_html($desc) . "</p>";
                }
                ?>
					<?php 
            }
            ?>
						
					<div class="<?php 
            echo $show_type;
            ?>
 product-wrapper ">	
						<div class="product-inner">
							
							<?php 
            $current_row = 0;
            ?>
							
							<?php 
            woocommerce_product_loop_start();
            ?>
								
								<?php 
            $woocommerce_loop['columns'] = $columns;
            ?>
								
								<?php 
            while ($products->have_posts()) {
                $products->the_post();
                ?>
																									
									<?php 
                woocommerce_get_template_part('content', 'product');
                ?>
									
									
								<?php 
            }
            // end of the loop.
            ?>
							<?php 
            woocommerce_product_loop_end();
            ?>
							
						</div>
					</div>	
					<div class="clear"></div>
				</div>
				
			<?php 
        }
        wp_reset_postdata();
        wd_restore_function_to_product_hook();
        $woocommerce_loop['columns'] = $_old_woocommerce_loop_columns;
        if (isset($_old_wd_prod_cat_column) && absint($_old_wd_prod_cat_column > 0)) {
            $wd_data['wd_prod_cat_column'] = $_old_wd_prod_cat_column;
        }
        return '<div class="woocommerce">' . ob_get_clean() . '</div>';
    }
Example #29
0
			<?php 
    woocommerce_product_loop_end();
    ?>

			<?php 
    /**
     * woocommerce_after_shop_loop hook
     *
     * @hooked woocommerce_pagination - 10
     */
    do_action('woocommerce_after_shop_loop');
    ?>
			</div>
		<?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 
}
?>
		
	<?php 
/**
 * woocommerce_after_main_content hook
 *
 * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
    /**
     * List products with an attribute shortcode
     * Example [product_attribute attribute='color' filter='black']
     *
     * @access public
     * @param array $atts
     * @return string
     */
    public static function product_attribute($atts)
    {
        global $woocommerce_loop;
        extract(shortcode_atts(array('per_page' => '12', 'columns' => '4', 'orderby' => 'title', 'order' => 'asc', 'attribute' => '', 'filter' => ''), $atts));
        $attribute = strstr($attribute, 'pa_') ? sanitize_title($attribute) : 'pa_' . sanitize_title($attribute);
        $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')), 'tax_query' => array(array('taxonomy' => $attribute, 'terms' => array_map('sanitize_title', explode(",", $filter)), 'field' => 'slug')));
        ob_start();
        $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
        $woocommerce_loop['columns'] = $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">' . ob_get_clean() . '</div>';
    }