Fix GooglePay mini-cart button loading

Fix GooglePay shipping callback
Fix GooglePay button on cart updates
This commit is contained in:
Pedro Silva 2023-10-17 10:47:26 +01:00
parent 9ab11b40e4
commit 84e4c2c40a
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
4 changed files with 59 additions and 21 deletions

View file

@ -168,7 +168,7 @@ class UpdatePaymentDataEndpoint {
* @return void
*/
private function update_addresses( array $payment_data ): void {
if ( ( $payment_data['callbackTrigger'] ?? '' ) !== 'SHIPPING_ADDRESS' ) {
if ( ! in_array( $payment_data['callbackTrigger'] ?? '', array( 'SHIPPING_ADDRESS', 'INITIALIZE' ), true ) ) {
return;
}
@ -185,11 +185,13 @@ class UpdatePaymentDataEndpoint {
$customer->set_billing_postcode( $payment_data['shippingAddress']['postalCode'] ?? '' );
$customer->set_billing_country( $payment_data['shippingAddress']['countryCode'] ?? '' );
$customer->set_billing_state( $payment_data['shippingAddress']['locality'] ?? '' );
$customer->set_billing_state( '' );
$customer->set_billing_city( $payment_data['shippingAddress']['locality'] ?? '' );
$customer->set_shipping_postcode( $payment_data['shippingAddress']['postalCode'] ?? '' );
$customer->set_shipping_country( $payment_data['shippingAddress']['countryCode'] ?? '' );
$customer->set_shipping_state( $payment_data['shippingAddress']['locality'] ?? '' );
$customer->set_shipping_state( '' );
$customer->set_shipping_city( $payment_data['shippingAddress']['locality'] ?? '' );
// Save the data.
$customer->save();