Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Change the order of free products shown
- This topic has 1 reply, 2 voices, and was last updated 5 years, 2 months ago by Soft79.
- AuthorPosts
- June 27, 2021 at 9:04 pm #17791eli0086Participant
Is there a way to customize the order of free products shown on checkout? We have our products set up with woocommerce’s menu order setting, and also by newest products. We’d like to be able to show the newest products first when displaying the free products available. Instead, it seems to be the opposite of what we want.
How can we change this?
June 28, 2021 at 8:19 pm #17799Soft79KeymasterHi,
Sorry for the somewhat late reply.
There’s no out-of-the-box solution for that. It’s possible by using a template override though. You will need some php experience.
First copy wp-content/plugins/woocommerce-auto-added-coupons-pro/templates/coupon-select-free-product.php into wp-content/themes/YOUR-CHILD-THEME/woocommerce-auto-added-coupons/
Then edit this new file. Before the
foreach-loop you need to reorder the$form_items-array, for example by usinguasortand a custom callback that orders by menu_order. Something like this (untested):uasort( $form_items, function( $a, $b ) { return $a->getProduct()->get_menu_order() <=> $b->getProduct()->get_menu_order(); } ); - AuthorPosts
- You must be logged in to reply to this topic.