Don't add notices during REST requests#843
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents WooCommerce session notices from being added during Store API / REST requests, avoiding a scenario where checkout failures leave persistent notices in the session that later get surfaced by cart validation as a woocommerce_rest_cart_item_error (409), blocking subsequent payment retries in Block Checkout.
Changes:
- Gate the
wc_add_notice()call inmark_order_as_failed()behind! SV_WC_Helper::is_rest_api_request(). - Prevent
add_debug_message()from adding WooCommerce notices during REST requests (while still allowing logging earlier in the method). - Add a changelog entry describing the Block Checkout retry fix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| woocommerce/payment-gateway/class-sv-wc-payment-gateway.php | Skips adding session-backed notices during REST/Store API requests in failure/debug paths to prevent notice leakage into subsequent cart validation. |
| woocommerce/changelog.txt | Documents the fix in the upcoming release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
agibson-godaddy
added a commit
that referenced
this pull request
Jun 15, 2026
* Version 6.2.2 * Don't add notices during REST requests (#843) * Set release date --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Ashley Gibson <[email protected]> Co-authored-by: Ashley Gibson <[email protected]>
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.
MWC-19933
Summary
On Block Checkout, when an SV-framework gateway transaction fails,
mark_order_as_failed()andadd_debug_message()push the error into the WC session viawc_add_notice(). The Store API never renders or clears those notices, soCartController::validate_cart()sweeps them on the next request and throws a 409woocommerce_rest_cart_item_error— blocking any retry, even with a valid card. This PR gates bothwc_add_notice()calls on! SV_WC_Helper::is_rest_api_request(); the message is already returned in theprocess_payment()result and surfaced viaRouteException, so the session notice is redundant in REST.QA steps
4123456789010343