• The theme I am using is called Bonfire.

    On the single-product.php template, I want to be able to call the upsells of a product. Is there something like

    <?php woocommerce_related_products( 4, 4, 'rand' ); ?> I can do. Right now I have

    <?php get_header('shop'); ?>
    
    <?php do_action('woocommerce_before_main_content'); ?>
    
    <div class="inner-container clearfix">
    
    	<!--<div class="page-single page-sidebar">-->
    
    	<div id="product" class="clearfix">
    
    	<?php custom_woocommerce_single_product_content(); ?>
    
    	</div>
    
    	<div id="sidebar">
    
    	<?php dynamic_sidebar('woo-single-sidebar'); ?>
    
    	</div>
    
    </div>
    <!-- Start UpSells Section-->
    <?php
    /**
     * Up-sells
     */
    
    global $product;
    $upsells = $product->get_upsells();
    if (sizeof($upsells)==0) return;
    ?>
    <div class="upsellss products">
    	<h2><?php _e('Other Jugz Models&hellip;', 'woocommerce') ?></h2>
    	<?php
    	$args = array(
    		'post_type'	=> 'product',
    		'ignore_sticky_posts'	=> 1,
    		'posts_per_page' => 3,
    		'orderby' => 'rand',
    		'post__in' => $upsells
    	);
    	query_posts($args);
    	woocommerce_get_template_part( 'loop', 'shop' );
    	wp_reset_query();
    	?>
    </div>
    
    <!--Stop UpSells Section -->
    <div class="product-tabs">
    	<?php do_action('woocommerce_after_single_product_summary'); ?>
    
    </div>
    
    <?php woocommerce_related_products( 4, 4, 'rand' ); ?>
    
    <?php get_footer('shop'); ?>

    So as you can see on https://www.jugzstore.com/shop/gloss-black-grey-polarized-5059d/, when you refresh the page, the Other Jugz Models (3 products) randomly change. How do I get it just to show the upsells attached to the product posts?

    Thank you in advanced.

  • The topic ‘Woo Comerce- Upsells displaying randomly’ is closed to new replies.