Repository navigation
[Backport to release/11.2] Revert apostrophe encoding in classic checkout requests - #69649
Conversation
This reverts commit 975cd3b (#68365). It restores the 11.1 request shape. update_order_review, apply_coupon and remove_coupon pass a data object to $.ajax() again, so fields removed with checkout field filters are dropped instead of being sent as empty values that blank the customer's country, state and postcode. Third-party ajaxPrefilter callbacks get the data object again rather than a pre-serialized string. Place order sends $form.serialize() as before. The #68365 tests are replaced with tests for the restored request shape. The apostrophe encoding will be re-landed separately. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Testing GuidelinesHi @mcliwanow , Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed. Reminder: PR reviewers are required to document testing performed. This includes:
|
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a commit that changes plugin code. |
|
Size Change: 0 B 🆕 Total Size: 0 B |
This PR is a cherry-pick of #69644 to
release/11.2.Original PR Description
Why
#68365 changed the classic checkout to send
update_order_reviewand coupon requests as a pre-serialized string (encodeApostrophes( $.param( data ) )) instead of a data object. That has two side effects in 11.2.0.$.param()turns fields removed viawoocommerce_checkout_fields/woocommerce_billing_fieldsinto empty values (country=&state=), where$.ajax()used to drop them, so the session customer's country, state and postcode get blanked. Withbilling_countryremoved and "Force shipping to the customer billing address" (orwoocommerce_cart_needs_shipping_addressfalse), place order fails with "Please enter an address to continue." for guests and logged-in customers. With postcode/state removed and "Hide shipping costs until an address is entered", shipping options disappear for logged-in customers. Reports: https://wordpress.org/support/topic/problems-with-checkout-after-last-update-to-11-2-0/ and https://wordpress.org/support/topic/shipping-method-disappears-in-classic-checkout-after-woocommerce-11-2-0/ (the first reporter's snippet follows our own checkout fields tutorial).jQuery.ajaxPrefiltercallbacks that readoriginalOptions.dataas an object now get a string (e.g. HurryTimer's coupon expiry check, Global Seller Services).Reverting restores the 11.1 behaviour. I reproduced it locally on 11.2.0: with only #68365's
checkout.jshunks reversed, the blocked orders go through for guests and logged-in customers. The apostrophe/WAF fix from #68365 will be re-landed separately (passing the object to$.ajaxand encoding inbeforeSend), with tests for removed fields and prefilters.What changed
update_order_review,apply_couponandremove_couponpass the data object to$.ajax()again, so undefined (removed) fields are dropped and prefilters see an object inoriginalOptions.data.$form.serialize()unchanged.encodeApostrophes()helper is removed fromcheckout.js. The copy incart.jsfrom Fix apostrophe encoding in classic cart requests #68556 (11.3.0, not in 11.2) is untouched.Testing
add_filter( 'woocommerce_billing_fields', function ( $f ) { unset( $f['billing_country'], $f['billing_state'] ); return $f; } );and set WooCommerce > Settings > Shipping > Shipping destination to "Force shipping to the customer billing address".[woocommerce_checkout]page) with a physical product in the cart, fill the visible fields and place the order. It fails with "Please enter an address to continue."update_order_reviewrequest no longer containscountry=orstate=.Automated:
pnpm test:js -- frontend/test/checkoutinplugins/woocommerce/client/legacypasses (21 tests on trunk, 20 on a local cherry-pick torelease/11.2, which applies without conflicts).eslintoncheckout.jsand the test file reports no errors.🤖 Generated with Claude Code