mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
Hide card button in previews when has acdc or separate gateway
This commit is contained in:
parent
47728a78ff
commit
c72a335cdd
4 changed files with 33 additions and 3 deletions
|
@ -96,6 +96,11 @@ document.addEventListener(
|
|||
renderPreview(settingsCallback, render);
|
||||
}
|
||||
|
||||
function currentTabId() {
|
||||
const params = new URLSearchParams(location.search);
|
||||
return params.has('ppcp-tab') ? params.get('ppcp-tab') : params.get('section');
|
||||
}
|
||||
|
||||
function shouldShowPayLaterButton() {
|
||||
const payLaterButtonLocations = document.querySelector('[name="ppcp[pay_later_button_locations][]"]');
|
||||
|
||||
|
@ -106,6 +111,14 @@ document.addEventListener(
|
|||
return payLaterButtonInput.checked && payLaterButtonLocations.selectedOptions.length > 0
|
||||
}
|
||||
|
||||
function shouldDisableCardButton() {
|
||||
if (currentTabId() === 'ppcp-card-button-gateway') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return PayPalCommerceGatewaySettings.is_acdc_enabled || jQuery('#ppcp-allow_card_button_gateway').is(':checked');
|
||||
}
|
||||
|
||||
function getPaypalScriptSettings() {
|
||||
const disableFundingInput = jQuery('[name="ppcp[disable_funding][]"]');
|
||||
let disabledSources = disableFundingInput.length > 0 ? disableFundingInput.val() : PayPalCommerceGatewaySettings.disabled_sources;
|
||||
|
@ -130,6 +143,10 @@ document.addEventListener(
|
|||
disabledSources = disabledSources.concat('credit')
|
||||
}
|
||||
|
||||
if (shouldDisableCardButton()) {
|
||||
disabledSources = disabledSources.concat('card');
|
||||
}
|
||||
|
||||
if (disabledSources?.length) {
|
||||
settings['disable-funding'] = disabledSources;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue