woocommerce/templates/single-product/up-sells.php

43 lines
776 B
PHP
Raw Normal View History

2011-12-12 12:28:07 +00:00
<?php
/**
* Up-sells
*/
2012-07-11 14:13:06 +00:00
global $product, $woocommerce_loop;
2011-12-12 12:28:07 +00:00
$upsells = $product->get_upsells();
2012-07-11 14:13:06 +00:00
if ( sizeof( $upsells ) == 0 ) return;
$args = array(
'post_type' => 'product',
'ignore_sticky_posts' => 1,
'posts_per_page' => 4,
'no_found_rows' => 1,
'orderby' => 'rand',
'post__in' => $upsells
);
$products = new WP_Query( $args );
if ( $products->have_posts() ) : ?>
<div class="upsells products">
<h2><?php _e('You may also like&hellip;', 'woocommerce') ?></h2>
<ul class="products">
<?php while ( $products->have_posts() ) : $products->the_post(); ?>
<?php woocommerce_get_template_part( 'content', 'product' ); ?>
<?php endwhile; // end of the loop. ?>
</ul>
2012-07-20 12:57:18 +00:00
2012-07-11 14:13:06 +00:00
</div>
<?php endif;
wp_reset_postdata();