diff --git a/modules/ppcp-onboarding/resources/js/settings.js b/modules/ppcp-onboarding/resources/js/settings.js index fb8e2e4e3..41610cb90 100644 --- a/modules/ppcp-onboarding/resources/js/settings.js +++ b/modules/ppcp-onboarding/resources/js/settings.js @@ -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')) }); diff --git a/modules/ppcp-onboarding/src/Assets/OnboardingAssets.php b/modules/ppcp-onboarding/src/Assets/OnboardingAssets.php index b28c1a254..7d57da2d5 100644 --- a/modules/ppcp-onboarding/src/Assets/OnboardingAssets.php +++ b/modules/ppcp-onboarding/src/Assets/OnboardingAssets.php @@ -110,6 +110,16 @@ class OnboardingAssets { $this->version, true ); + wp_localize_script( + 'ppcp-settings', + 'PayPalCommerceGatewaySettings', + array( + 'empty_smart_button_location_message' => sprintf( + '

%1$s

', + __( '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(