mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
Add needs shipping to block pages
This commit is contained in:
parent
af286c8f82
commit
c199ce1f8b
2 changed files with 17 additions and 11 deletions
|
@ -227,7 +227,7 @@ const PayPalComponent = ( {
|
||||||
throw new Error( config.scriptData.labels.error.generic );
|
throw new Error( config.scriptData.labels.error.generic );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! shouldHandleShippingInPayPal() ) {
|
if ( ! shouldskipFinalConfirmation() ) {
|
||||||
location.href = getCheckoutRedirectUrl();
|
location.href = getCheckoutRedirectUrl();
|
||||||
} else {
|
} else {
|
||||||
setGotoContinuationOnError( true );
|
setGotoContinuationOnError( true );
|
||||||
|
@ -318,7 +318,7 @@ const PayPalComponent = ( {
|
||||||
throw new Error( config.scriptData.labels.error.generic );
|
throw new Error( config.scriptData.labels.error.generic );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! shouldHandleShippingInPayPal() ) {
|
if ( ! shouldskipFinalConfirmation() ) {
|
||||||
location.href = getCheckoutRedirectUrl();
|
location.href = getCheckoutRedirectUrl();
|
||||||
} else {
|
} else {
|
||||||
setGotoContinuationOnError( true );
|
setGotoContinuationOnError( true );
|
||||||
|
@ -364,16 +364,20 @@ const PayPalComponent = ( {
|
||||||
};
|
};
|
||||||
|
|
||||||
const shouldHandleShippingInPayPal = () => {
|
const shouldHandleShippingInPayPal = () => {
|
||||||
if ( config.finalReviewEnabled ) {
|
return shouldskipFinalConfirmation() && config.needShipping
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
window.ppcpFundingSource !== 'venmo' ||
|
|
||||||
! config.scriptData.vaultingEnabled
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const shouldskipFinalConfirmation = () => {
|
||||||
|
if ( config.finalReviewEnabled ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
window.ppcpFundingSource !== 'venmo' ||
|
||||||
|
! config.scriptData.vaultingEnabled
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
let handleShippingOptionsChange = null;
|
let handleShippingOptionsChange = null;
|
||||||
let handleShippingAddressChange = null;
|
let handleShippingAddressChange = null;
|
||||||
let handleSubscriptionShippingOptionsChange = null;
|
let handleSubscriptionShippingOptionsChange = null;
|
||||||
|
@ -544,7 +548,7 @@ const PayPalComponent = ( {
|
||||||
if ( config.scriptData.continuation ) {
|
if ( config.scriptData.continuation ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( shouldHandleShippingInPayPal() ) {
|
if ( shouldskipFinalConfirmation() ) {
|
||||||
location.href = getCheckoutRedirectUrl();
|
location.href = getCheckoutRedirectUrl();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -210,6 +210,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
||||||
*/
|
*/
|
||||||
public function get_payment_method_data() {
|
public function get_payment_method_data() {
|
||||||
$script_data = $this->smart_button()->script_data();
|
$script_data = $this->smart_button()->script_data();
|
||||||
|
$cart = WC()->cart;
|
||||||
|
|
||||||
if ( isset( $script_data['continuation'] ) ) {
|
if ( isset( $script_data['continuation'] ) ) {
|
||||||
$url = add_query_arg( array( CancelController::NONCE => wp_create_nonce( CancelController::NONCE ) ), wc_get_checkout_url() );
|
$url = add_query_arg( array( CancelController::NONCE => wp_create_nonce( CancelController::NONCE ) ), wc_get_checkout_url() );
|
||||||
|
@ -254,6 +255,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'scriptData' => $script_data,
|
'scriptData' => $script_data,
|
||||||
|
'needShipping' => $cart && $cart->needs_shipping(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue