Closed csmcneill closed 3 months ago
A temporary workaround until this is sorted:
// Make the County (UK), and Region (NZ) mandatory fields.
add_filter('woocommerce_get_country_locale', function($locale) {
$locale['GB']['state']['required'] = true;
$locale['NZ']['state']['required'] = true;
return $locale;
});
P.S: Not extensively tested. Try it on a staging/test env first before implementing on production.
@AashikP did you test this on shortcode and block-based checkout?
did you test this on shortcode and block-based checkout?
Originally, I only tested in shortcode-based checkout, but it seems to work fine in the checkout block as well:
Describe the bug
In WooCommerce Core, customers using a UK or NZ address have optional fields:
County
andRegion
respectively. Both of these fields are passed asbilling_state
.However, Afterpay via WooPayments requires that a
state
value be passed for physical products:https://github.com/Automattic/woocommerce-payments/blob/50a2090375813418c8bb51ae49c822a57ed6d9d4/includes/class-wc-payment-gateway-wcpay.php#L4498-L4501
If it is not, an exception will be thrown:
https://github.com/Automattic/woocommerce-payments/blob/50a2090375813418c8bb51ae49c822a57ed6d9d4/includes/class-wc-payment-gateway-wcpay.php#L4521
As a result, customers attempting to make a purchase via Afterpay who leave these optional fields empty will experience an error on checkout — even though the address they are using is correct.
In my tests:
$address['state']
string in thehandle_afterpay_shipping_requirement
filter allows a test payment to be placed.To Reproduce
County
field blank.Actual behavior
Customers in NZ and UK cannot place orders via Afterpay unless they provide optional address details. The error does not indicate that the optional information is a requirement, which leads to reduced conversions, confused customers, and frustrated merchants.
Expected behavior
Either Afterpay:
Additional context
p1719933634918299-slack-C3NCP7ZJ6 p1720025787369259-slack-CU6SYV31A 8421059-zen