mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Prevent enabling Standard Card Button when ACDC is enabled
This commit is contained in:
parent
36a13f6500
commit
49faab654a
3 changed files with 44 additions and 9 deletions
|
@ -125,10 +125,6 @@ document.addEventListener(
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldDisableCardButton() {
|
function shouldDisableCardButton() {
|
||||||
if (currentTabId() === 'ppcp-card-button-gateway') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return PayPalCommerceGatewaySettings.is_acdc_enabled || jQuery('#ppcp-allow_card_button_gateway').is(':checked');
|
return PayPalCommerceGatewaySettings.is_acdc_enabled || jQuery('#ppcp-allow_card_button_gateway').is(':checked');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,6 +153,11 @@ document.addEventListener(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldDisableCardButton()) {
|
if (shouldDisableCardButton()) {
|
||||||
|
const standardCardButtonInput = document.querySelector('#woocommerce_ppcp-card-button-gateway_enabled');
|
||||||
|
if (standardCardButtonInput) {
|
||||||
|
standardCardButtonInput.disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
disabledSources = disabledSources.concat('card');
|
disabledSources = disabledSources.concat('card');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ class GatewayWithoutPayPalAdminNotice {
|
||||||
private const NOTICE_OK = '';
|
private const NOTICE_OK = '';
|
||||||
private const NOTICE_DISABLED_GATEWAY = 'disabled_gateway';
|
private const NOTICE_DISABLED_GATEWAY = 'disabled_gateway';
|
||||||
private const NOTICE_DISABLED_LOCATION = 'disabled_location';
|
private const NOTICE_DISABLED_LOCATION = 'disabled_location';
|
||||||
|
private const NOTICE_DISABLED_CARD_BUTTON = 'disabled_card';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The gateway ID.
|
* The gateway ID.
|
||||||
|
@ -114,6 +115,15 @@ class GatewayWithoutPayPalAdminNotice {
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case self::NOTICE_DISABLED_CARD_BUTTON:
|
||||||
|
/* translators: %1$s Standard Card Button section URL, %2$s Advanced Card Processing section URL. */
|
||||||
|
$text = __(
|
||||||
|
'The <a href="%1$s">Standard Card Button</a> cannot be used while <a href="%2$s">Advanced Card Processing</a> is enabled.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
);
|
||||||
|
$url1 = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-card-button-gateway' );
|
||||||
|
$url2 = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&ppcp-tab=ppcp-credit-card-gateway' );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -125,11 +135,20 @@ class GatewayWithoutPayPalAdminNotice {
|
||||||
|
|
||||||
$name = $gateway->get_method_title();
|
$name = $gateway->get_method_title();
|
||||||
|
|
||||||
$message = sprintf(
|
if ( $notice_type === self::NOTICE_DISABLED_CARD_BUTTON ) {
|
||||||
$text,
|
$message = sprintf(
|
||||||
$name,
|
$text,
|
||||||
admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway' )
|
$url1,
|
||||||
);
|
$url2
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$message = sprintf(
|
||||||
|
$text,
|
||||||
|
$name,
|
||||||
|
admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway' )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return new Message( $message, 'warning' );
|
return new Message( $message, 'warning' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +179,13 @@ class GatewayWithoutPayPalAdminNotice {
|
||||||
return self::NOTICE_DISABLED_LOCATION;
|
return self::NOTICE_DISABLED_LOCATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$is_dcc_enabled = $this->settings->has( 'dcc_enabled' ) && $this->settings->get( 'dcc_enabled' ) ?? false;
|
||||||
|
$is_card_button_allowed = $this->settings->has( 'allow_card_button_gateway' ) && $this->settings->get( 'allow_card_button_gateway' );
|
||||||
|
|
||||||
|
if ( $is_dcc_enabled && $is_card_button_allowed ) {
|
||||||
|
return self::NOTICE_DISABLED_CARD_BUTTON;
|
||||||
|
}
|
||||||
|
|
||||||
return self::NOTICE_OK;
|
return self::NOTICE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -528,6 +528,14 @@ class WCGatewayModule implements ModuleInterface {
|
||||||
return $methods;
|
return $methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$is_dcc_enabled = $settings->has( 'dcc_enabled' ) && $settings->get( 'dcc_enabled' ) ?? false;
|
||||||
|
$standard_card_button = get_option( 'woocommerce_ppcp-card-button-gateway_settings' );
|
||||||
|
|
||||||
|
if ( $is_dcc_enabled && isset( $standard_card_button['enabled'] ) ) {
|
||||||
|
$standard_card_button['enabled'] = 'no';
|
||||||
|
update_option( 'woocommerce_ppcp-card-button-gateway_settings', $standard_card_button );
|
||||||
|
}
|
||||||
|
|
||||||
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
||||||
assert( $dcc_applies instanceof DccApplies );
|
assert( $dcc_applies instanceof DccApplies );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue