diff --git a/modules/ppcp-blocks/resources/js/checkout-block.js b/modules/ppcp-blocks/resources/js/checkout-block.js index 6df1a99f8..bf36dcb65 100644 --- a/modules/ppcp-blocks/resources/js/checkout-block.js +++ b/modules/ppcp-blocks/resources/js/checkout-block.js @@ -606,9 +606,11 @@ const PayPalComponent = ( { } return ( data, actions ) => { - shouldHandleShippingInPayPal() + let shippingAddressChange = shouldHandleShippingInPayPal() ? handleShippingAddressChange( data, actions ) : null; + + return shippingAddressChange; }; }; diff --git a/modules/ppcp-blocks/src/Endpoint/UpdateShippingEndpoint.php b/modules/ppcp-blocks/src/Endpoint/UpdateShippingEndpoint.php index f9322700d..be196fa03 100644 --- a/modules/ppcp-blocks/src/Endpoint/UpdateShippingEndpoint.php +++ b/modules/ppcp-blocks/src/Endpoint/UpdateShippingEndpoint.php @@ -22,7 +22,8 @@ * Class UpdateShippingEndpoint */ class UpdateShippingEndpoint implements EndpointInterface { - const ENDPOINT = 'ppc-update-shipping'; + const ENDPOINT = 'ppc-update-shipping'; + const WC_STORE_API_ENDPOINT = '/wp-json/wc/store/cart/'; /** * The Request Data Helper. diff --git a/modules/ppcp-button/resources/js/modules/Renderer/Renderer.js b/modules/ppcp-button/resources/js/modules/Renderer/Renderer.js index b70342dbf..448432e3c 100644 --- a/modules/ppcp-button/resources/js/modules/Renderer/Renderer.js +++ b/modules/ppcp-button/resources/js/modules/Renderer/Renderer.js @@ -141,6 +141,7 @@ class Renderer { // Check the condition and add the handler if needed if ( this.defaultSettings.should_handle_shipping_in_paypal ) { options.onShippingOptionsChange = ( data, actions ) => { + let shippingOptionsChange = ! this.isVenmoButtonClickedWhenVaultingIsEnabled( venmoButtonClicked ) @@ -150,8 +151,11 @@ class Renderer { this.defaultSettings ) : null; + + return shippingOptionsChange }; options.onShippingAddressChange = ( data, actions ) => { + let shippingAddressChange = ! this.isVenmoButtonClickedWhenVaultingIsEnabled( venmoButtonClicked ) @@ -161,6 +165,8 @@ class Renderer { this.defaultSettings ) : null; + + return shippingAddressChange }; } diff --git a/modules/ppcp-button/src/Assets/SmartButton.php b/modules/ppcp-button/src/Assets/SmartButton.php index 6b92a9084..4b309818e 100644 --- a/modules/ppcp-button/src/Assets/SmartButton.php +++ b/modules/ppcp-button/src/Assets/SmartButton.php @@ -1165,11 +1165,11 @@ public function script_data(): array { ), 'update_customer_shipping' => array( 'shipping_options' => array( - 'endpoint' => '/wp-json/wc/store/cart/select-shipping-rate', + 'endpoint' => home_url( UpdateShippingEndpoint::WC_STORE_API_ENDPOINT . 'select-shipping-rate' ), ), 'shipping_address' => array( - 'cart_endpoint' => '/wp-json/wc/store/cart/', - 'update_customer_endpoint' => '/wp-json/wc/store/v1/cart/update-customer/', + 'cart_endpoint' => home_url( UpdateShippingEndpoint::WC_STORE_API_ENDPOINT ), + 'update_customer_endpoint' => home_url( UpdateShippingEndpoint::WC_STORE_API_ENDPOINT . 'update-customer' ), ), 'wp_rest_nonce' => wp_create_nonce( 'wc_store_api' ), 'update_shipping_method' => \WC_AJAX::get_endpoint( 'update_shipping_method' ),