mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Conditionally add a message when no location is selected.
This commit is contained in:
parent
eb080c9275
commit
5b15b4b3fe
2 changed files with 16 additions and 0 deletions
|
@ -187,9 +187,13 @@ document.addEventListener(
|
|||
const toggleElementsBySelectedLocations = () => {
|
||||
stylingPerElementWrapper.style.display = '';
|
||||
let selectedLocations = getSelectedLocations(locationsSelector);
|
||||
let emptySmartButtonLocationMessage = jQuery('.ppcp-empty-smart-button-location');
|
||||
|
||||
if(selectedLocations.length === 0) {
|
||||
hideElements(groupToHideOnChecked.concat(stylingPerElementWrapperSelector));
|
||||
if (emptySmartButtonLocationMessage.length === 0) {
|
||||
jQuery(PayPalCommerceGatewaySettings.empty_smart_button_location_message).insertAfter(jQuery(smartButtonLocationsSelector).find('.description'));
|
||||
}
|
||||
}
|
||||
|
||||
if (! stylingPerElement.checked) {
|
||||
|
@ -257,6 +261,8 @@ document.addEventListener(
|
|||
|
||||
// We need to use jQuery here as the select might be a select2 element, which doesn't use native events.
|
||||
jQuery(locationsElement).on('change', function (){
|
||||
let emptySmartButtonLocationMessage = jQuery('.ppcp-empty-smart-button-location');
|
||||
emptySmartButtonLocationMessage?.remove();
|
||||
toggleElementsBySelectedLocations()
|
||||
stylingPerElement.dispatchEvent(new Event('change'))
|
||||
});
|
||||
|
|
|
@ -110,6 +110,16 @@ class OnboardingAssets {
|
|||
$this->version,
|
||||
true
|
||||
);
|
||||
wp_localize_script(
|
||||
'ppcp-settings',
|
||||
'PayPalCommerceGatewaySettings',
|
||||
array(
|
||||
'empty_smart_button_location_message' => sprintf(
|
||||
'<p class="description ppcp-empty-smart-button-location">%1$s</p>',
|
||||
__( 'Note: If no button location is selected, the PayPal gateway will not be available.', 'woocommerce-paypal-payments' )
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$url = untrailingslashit( $this->module_url ) . '/assets/js/onboarding.js';
|
||||
wp_register_script(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue