Skip to content

Commit

Permalink
Merge pull request #2421 from woocommerce/PCP-3305-shipping-methods-d…
Browse files Browse the repository at this point in the history
…uring-callback-not-updated-correctly

Shipping methods during callback not updated correctly (3305)
  • Loading branch information
Dinamiko authored Jul 16, 2024
2 parents 65aa05f + 2f0b01e commit 2bf6e5e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion modules/ppcp-blocks/resources/js/checkout-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,11 @@ const PayPalComponent = ( {
}

return ( data, actions ) => {
shouldHandleShippingInPayPal()
let shippingAddressChange = shouldHandleShippingInPayPal()
? handleShippingAddressChange( data, actions )
: null;

return shippingAddressChange;
};
};

Expand Down
3 changes: 2 additions & 1 deletion modules/ppcp-blocks/src/Endpoint/UpdateShippingEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions modules/ppcp-button/resources/js/modules/Renderer/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -150,8 +151,11 @@ class Renderer {
this.defaultSettings
)
: null;

return shippingOptionsChange
};
options.onShippingAddressChange = ( data, actions ) => {
let shippingAddressChange =
! this.isVenmoButtonClickedWhenVaultingIsEnabled(
venmoButtonClicked
)
Expand All @@ -161,6 +165,8 @@ class Renderer {
this.defaultSettings
)
: null;

return shippingAddressChange
};
}

Expand Down
6 changes: 3 additions & 3 deletions modules/ppcp-button/src/Assets/SmartButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down

0 comments on commit 2bf6e5e

Please sign in to comment.