- This topic has 5 replies, 2 voices, and was last updated 3 years, 3 months ago by
David.
-
AuthorPosts
-
February 9, 2023 at 4:03 am #2527015
Matthew
Does GeneratePress allow setting of the ordering direction parameter when displaying WooCommerce Upsells?
I am trying to order Upsells by menu_order ascending. I have used the WooCommerce filter ‘woocommerce_upsells_orderby’ to set the ‘menu_order’ however WooCommerce doesn’t provide a filter to set the query direction, any chance that GeneratePress does?
February 9, 2023 at 4:49 am #2527070David
StaffCustomer SupportHi there,
GP doesn’t interfere ( where possible ) with what woo does.
I had a look to see how Woo displays the upsells.
And it uses thewoocommerce_upsell_display()function.Which i tracked to this:
And it has one main $args filter:
woocommerce_upsell_display_argsAnd it has an individual filter for the
order->woocommerce_upsells_orderDoes that help ?
February 9, 2023 at 6:58 am #2527168Matthew
Hi David,
Thanks for looking into it.
My question would be when GeneratePress calls the
woocommerce_upsell_display()function is there anyway to set the$ordervar to be ‘ASC’ instead of the default ‘DESC’.I am using the WooCommerce filter already to change the order_by parameter but cannot change the order parameter.
So I get my upsells shown in menu_order by back-to-front instead of front-to-back. I did have a look at the woocommerce_upsell_display function as it doesn’t have a filter to changing the ordering.
February 9, 2023 at 9:17 am #2527512David
StaffCustomer SupportGP doesn’t make that callback.
Its made by the woo template
The only time GPP gets in the way is if the Customizer > Layout > Woocommerce options have it disabled, and then we simply unhook that function ie.remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );I am not sure what the issue is, but there are the:
woocommerce_upsell_display_argsand the specificwoocommerce_upsells_orderfilters … do those not work ?If they don’t then you could:
1. Unhook the
woocommerce_upsell_display// remove the upsells action remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );2. Hook in a custom callback for it eg.:
add_action( 'woocommerce_after_single_product_summary', 'get_custom_upsell_display', 15 ); function get_custom_upsell_display() { // woocommerce_upsell_display( $limit = '-1', $columns = 4, $orderby = 'rand', $order = 'desc' ) woocommerce_upsell_display( -1, 4, 'menu_order', 'asc' ); }February 9, 2023 at 9:28 am #2527531Matthew
David,
I am so sorry, you are correct there is the ‘woocommerce_upsells_order’ filter. I totally did not see that!!!
My apologies for wasting your time.
Many Kind Regards,
Matt
February 9, 2023 at 9:33 am #2527537David
StaffCustomer SupportNo apologies necessary 🙂 Glad to be of help!
-
AuthorPosts
- You must be logged in to reply to this topic.