Skip auto-applying EDD discount when product requirements aren't met#185
Open
zackkatz wants to merge 3 commits intostrangerstudios:devfrom
Open
Skip auto-applying EDD discount when product requirements aren't met#185zackkatz wants to merge 3 commits intostrangerstudios:devfrom
zackkatz wants to merge 3 commits intostrangerstudios:devfrom
Conversation
When Sitewide Sales auto-applies an EDD discount, check if the cart contents satisfy the discount's product requirements first. If not (e.g., lifetime products in cart with an annual-only discount), silently skip applying rather than letting EDD reject it with a confusing error. Uses EDD's own is_product_requirements_met(false) to check without setting error messages in the session. Fixes strangerstudios#183
The product requirements check was preventing the discount from being set in the session on product pages. Restrict the check to the checkout page so sale pricing still displays on product pages. - Add edd_is_checkout() guard before product requirements check - Fixes regression from f2244ec
When a sitewide sale discount was auto-applied during browsing (empty cart), it persisted in the EDD session. If the customer then added a Lifetime product and went to checkout, the stale discount caused checkout to fail. Now checks product requirements on every page load (not just checkout) and actively removes the discount from both cart_discounts and preset_discount when requirements aren't met. Strike-through pricing on product pages is unaffected since it calculates directly from the EDD_Discount object without using the session.
Author
|
@flintfromthebasement What do you think? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
automatic_coupon_application(), it now checks if the cart contents satisfy the discount's product requirements before applyingis_product_requirements_met(false)— thefalseparameter suppresses error messages in the sessionTest plan