mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #2429 from woocommerce/PCP-3385-can-not-pay-from-block-cart-and-block-checkout-when-shipping-callback-enabled-and-no-shipping-methods-defined
Can't pay from block pages when the shipping callback is enabled and no shipping methods defined (3385)
This commit is contained in:
commit
8d0dd26f87
4 changed files with 18 additions and 12 deletions
|
@ -227,7 +227,7 @@ const PayPalComponent = ( {
|
|||
throw new Error( config.scriptData.labels.error.generic );
|
||||
}
|
||||
|
||||
if ( ! shouldHandleShippingInPayPal() ) {
|
||||
if ( ! shouldskipFinalConfirmation() ) {
|
||||
location.href = getCheckoutRedirectUrl();
|
||||
} else {
|
||||
setGotoContinuationOnError( true );
|
||||
|
@ -318,7 +318,7 @@ const PayPalComponent = ( {
|
|||
throw new Error( config.scriptData.labels.error.generic );
|
||||
}
|
||||
|
||||
if ( ! shouldHandleShippingInPayPal() ) {
|
||||
if ( ! shouldskipFinalConfirmation() ) {
|
||||
location.href = getCheckoutRedirectUrl();
|
||||
} else {
|
||||
setGotoContinuationOnError( true );
|
||||
|
@ -364,16 +364,20 @@ const PayPalComponent = ( {
|
|||
};
|
||||
|
||||
const shouldHandleShippingInPayPal = () => {
|
||||
if ( config.finalReviewEnabled ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
window.ppcpFundingSource !== 'venmo' ||
|
||||
! config.scriptData.vaultingEnabled
|
||||
);
|
||||
return shouldskipFinalConfirmation() && config.needShipping
|
||||
};
|
||||
|
||||
const shouldskipFinalConfirmation = () => {
|
||||
if ( config.finalReviewEnabled ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
window.ppcpFundingSource !== 'venmo' ||
|
||||
! config.scriptData.vaultingEnabled
|
||||
);
|
||||
};
|
||||
|
||||
let handleShippingOptionsChange = null;
|
||||
let handleShippingAddressChange = null;
|
||||
let handleSubscriptionShippingOptionsChange = null;
|
||||
|
@ -544,7 +548,7 @@ const PayPalComponent = ( {
|
|||
if ( config.scriptData.continuation ) {
|
||||
return true;
|
||||
}
|
||||
if ( shouldHandleShippingInPayPal() ) {
|
||||
if ( shouldskipFinalConfirmation() ) {
|
||||
location.href = getCheckoutRedirectUrl();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -254,6 +254,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
),
|
||||
),
|
||||
'scriptData' => $script_data,
|
||||
'needShipping' => WC()->cart->needs_shipping(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ class Renderer {
|
|||
};
|
||||
|
||||
// Check the condition and add the handler if needed
|
||||
if ( this.defaultSettings.should_handle_shipping_in_paypal ) {
|
||||
if ( this.defaultSettings.should_handle_shipping_in_paypal && this.defaultSettings.needShipping ) {
|
||||
options.onShippingOptionsChange = ( data, actions ) => {
|
||||
let shippingOptionsChange =
|
||||
! this.isVenmoButtonClickedWhenVaultingIsEnabled(
|
||||
|
|
|
@ -1295,6 +1295,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
|
|||
'is_logged' => is_user_logged_in(),
|
||||
),
|
||||
'should_handle_shipping_in_paypal' => $this->should_handle_shipping_in_paypal && ! $this->is_checkout(),
|
||||
'needShipping' => WC()->cart->needs_shipping(),
|
||||
'vaultingEnabled' => $this->settings->has( 'vault_enabled' ) && $this->settings->get( 'vault_enabled' ),
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue