Skip to content

Instantly share code, notes, and snippets.

@rynaldos-zz
Last active March 20, 2021 02:38
Show Gist options
  • Save rynaldos-zz/0d99df3bd2d83cac9fd519b4ac6bd18c to your computer and use it in GitHub Desktop.
Save rynaldos-zz/0d99df3bd2d83cac9fd519b4ac6bd18c to your computer and use it in GitHub Desktop.
[WooCommerce 3.0] Change number of upsells on single products
add_filter( 'woocommerce_output_related_products_args', 'wc_change_number_related_products' );
function wc_change_number_related_products( $args ) {
$args['posts_per_page'] = 1;
$args['columns'] = 4; //change number of upsells here
return $args;
}
@Uriel1339
Copy link

As far as I know that code never worked, might had been because we use the Divi theme by Elegant Themes. Either way, we had to make our own function with this:

add_filter( 'woocommerce_upsells_total', 'wc_upsell_display_number_change', 10, 1 );
	function wc_upsell_display_number_change( $args ) {
	$limit = '12';
}

And that in my opinion seems like a much more straightforward solution, at least in our case where we can manipulate the columns with our theme. But maybe this might be something that can be built upon.

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