Support » Plugin: WooCommerce » Apply biggest coupon first

  • Borja

    (@piesblancos)


    Hi! I’m trying to change the order of applyance of my coupons programmatically but I haven’t been able to achieve it.

    I have some coupons that my users can apply to their cart. The problem is that I need to apply the biggest (50% off) first, and the rest of them (if any) would be applied after it.
    How can I apply always this coupon first?

    Usually the order is not important, but the fact is that it is important in this project.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Please check this article. So probably you can create multiple variables in descending order of their values and apply them programatically in the same order.

    I think this is the simple way but you can see that the coupon names are hardcoded.

    Borja

    (@piesblancos)

    Thank you @prasad-nevase!

    I’ve already did that and it worked but maybe because of the hook I used, the code entered in a loop.

    Hook: woocommerce_applied_coupon
    So, when a coupon is applied, I check if my coupon is applied and if it is applied in first place. If it’s not, I remove the other coupons and apply this one first and then the others.
    The problem is that the hook fires every time a coupon is applied, so here becomes the loop.

    What I want to achieve is have the total calculation with the big coupon applied (which is hard coded) and then the small ones.

    Thanks again

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Apply biggest coupon first’ is closed to new replies.