Repository Forums Support WooCommerce Extended Coupon Features PRO Change the order of free products shown

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #17791

    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?



    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 using uasort and 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(); } );
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.