lunar icon indicating copy to clipboard operation
lunar copied to clipboard

Provide an option to automatically add BuyXGetY discount rewards

Open ryanmitchell opened this issue 8 months ago • 1 comments

3rd times a charm?

This PR provides an option to automatically add BuyXGetY discount rewards.

It adds a toggle to the discount create/edit screen to automatically add.

When selected we work out if any rewards are available that haven't yet been added to the cart and if we so we add them. Along the way we keep track of how many we added, so we can decrement/increment if cart values are changed, and if necessary remove the item from the cart when it no longer is eligible.

Devs can check for whether an item was added by discount by checking the meta->added_by_discount array values ... if the sum is the same as the cart line quantity then it was added by a discount and can be displayed differently (if required).

Replaces https://github.com/lunarphp/lunar/pull/881 Closes https://github.com/lunarphp/lunar/issues/876

ryanmitchell avatar Dec 19 '23 09:12 ryanmitchell