Add needs shipping to block pages

This commit is contained in:
Narek Zakarian 2024-07-17 16:44:35 +04:00
parent af286c8f82
commit c199ce1f8b
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7
2 changed files with 17 additions and 11 deletions

View file

@ -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,6 +364,10 @@ const PayPalComponent = ( {
};
const shouldHandleShippingInPayPal = () => {
return shouldskipFinalConfirmation() && config.needShipping
};
const shouldskipFinalConfirmation = () => {
if ( config.finalReviewEnabled ) {
return false;
}
@ -544,7 +548,7 @@ const PayPalComponent = ( {
if ( config.scriptData.continuation ) {
return true;
}
if ( shouldHandleShippingInPayPal() ) {
if ( shouldskipFinalConfirmation() ) {
location.href = getCheckoutRedirectUrl();
}
return true;

View file

@ -210,6 +210,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
*/
public function get_payment_method_data() {
$script_data = $this->smart_button()->script_data();
$cart = WC()->cart;
if ( isset( $script_data['continuation'] ) ) {
$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,
'needShipping' => $cart && $cart->needs_shipping(),
);
}