I’ll have a go if you can debug it:
// remove the upsells action using the same priority as original add_action()
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
// add my custom upsells function in the same place
add_action( 'woocommerce_after_single_product_summary', 'custom_upsell_display', 15 );
function custom_upsell_display() {
// default parameters:
// woocommerce_upsell_display( $limit = '-1', $columns = 4, $orderby = 'rand', $order = 'desc' )
// call it with my parameters
woocommerce_upsell_display( -1, 4, 'price', 'asc' );
}
Thread Starter
JayFry
(@jayfry)
Thank you for answer, but your solution worked in older versions of woocommerce. Now it is not, I have just tested it.
-
This reply was modified 7 years, 7 months ago by
JayFry.
I got it to work in 2017 theme and in storefront with a slight mod. All latest. If you are using a wordpress.org theme I’ll try it with that? In what way did it not work?
Thread Starter
JayFry
(@jayfry)
It is depending on woocommerce version and since release of v3.x your code is not working any more. Up-sells keeps being placed in random order on every page reload.
-
This reply was modified 7 years, 7 months ago by
JayFry.
-
This reply was modified 7 years, 7 months ago by
JayFry.
Working with WC 3.1.1 on 2017 theme.
What theme are you using?
Thread Starter
JayFry
(@jayfry)
You was totally right. Your code is working. The problem was in my functions.php, it had some code that was contradicting with yours.
Thank you a lot!