mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Hide subscription settings when checkout smart buttons disabled
This commit is contained in:
parent
21e0cf3c1d
commit
74b560c33c
1 changed files with 34 additions and 0 deletions
|
@ -462,6 +462,38 @@ document.addEventListener( 'DOMContentLoaded', () => {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Hide the subscription settings when smart buttons are disabled for checkout,
|
||||
* since the basic redirect gateway is disabled for subscriptions.
|
||||
*/
|
||||
const initSettingsHidingForPlaceOrderGateway = () => {
|
||||
const selectors = [
|
||||
'#field-paypal_saved_payments',
|
||||
'#field-subscriptions_mode',
|
||||
'#field-vault_enabled',
|
||||
];
|
||||
|
||||
const updateSettingsVisibility = () => {
|
||||
const selectedLocations = getSelectedLocations(
|
||||
smartButtonLocationsSelect
|
||||
);
|
||||
const hasCheckoutSmartButtons =
|
||||
selectedLocations.includes( 'checkout' ) ||
|
||||
selectedLocations.includes( 'checkout-block-express' );
|
||||
|
||||
selectors.forEach( ( selector ) => {
|
||||
setVisibleByClass( selector, hasCheckoutSmartButtons, 'hide' );
|
||||
} );
|
||||
};
|
||||
|
||||
updateSettingsVisibility();
|
||||
|
||||
jQuery( smartButtonLocationsSelect ).on(
|
||||
'change',
|
||||
updateSettingsVisibility
|
||||
);
|
||||
};
|
||||
|
||||
( () => {
|
||||
removeDisabledCardIcons(
|
||||
'select[name="ppcp[disable_cards][]"]',
|
||||
|
@ -493,6 +525,8 @@ document.addEventListener( 'DOMContentLoaded', () => {
|
|||
|
||||
toggleMessagingEnabled();
|
||||
|
||||
initSettingsHidingForPlaceOrderGateway();
|
||||
|
||||
groupToggle( '#ppcp-vault_enabled', [
|
||||
'#field-subscription_behavior_when_vault_fails',
|
||||
] );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue