Now setting the discount code ID on orders before saving #3190
+17
−18
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.
All Submissions:
Changes proposed in this Pull Request:
Currently, discount codes are set for orders after the orders have been saved. This means that the discount code attributes are not correct during the
pmpro_added_order
hook and thepmpro_updated_order
hook.This PR updates the logic when saving orders at checkout and on the Edit Order page to set the discount code during the order save process to make sure that those actions work as expected.
Note: When using offiste gateways (such as Stripe Checkout or PayPal Express), the discount code will still not be available during the
pmpro_added_order
hook. This is because the order is initially added intoken
status and is later updated tosuccess
with the discount code added once the checkout is complete. In these cases, it is best to use thepmpro_after_checkout
orpmpro_order_status_success
hooks.Other information:
Changelog entry