Skip to content

Instantly share code, notes, and snippets.

@jameskoster
Created February 12, 2012 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jameskoster/1811704 to your computer and use it in GitHub Desktop.
Save jameskoster/1811704 to your computer and use it in GitHub Desktop.
WooCommerce - Change number of upsells displayed and # of products per row
remove_action( 'woocommerce_after_single_product', 'woocommerce_upsell_display');
add_action( 'woocommerce_after_single_product', 'woocommerce_output_upsells', 20);
if (!function_exists('woocommerce_output_upsells')) {
function woocommerce_output_upsells() {
woocommerce_upsell_display(3,3); // Display 3 products in rows of 3
}
}
@dademaru
Copy link

Doesn't seem to work in 1.6.5.1.
I've tried this:
function woocommerce_upsell_display( $posts_per_page = 4, $columns = 3, $orderby = 'rand' ) { woocommerce_get_template( 'single-product/up-sells.php', array( 'posts_per_page' => $posts_per_page, 'orderby' => $orderby, 'columns' => $columns ) ); }
but I've noticed that in up-sells.php file there isn't the
$woocommerce_loop['columns'] = $columns;
you can find in related.php file.

@ejntaylor
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment