diff --git a/.megaignore b/.megaignore
new file mode 100644
index 000000000..6ad02d892
--- /dev/null
+++ b/.megaignore
@@ -0,0 +1 @@
+-s:*
\ No newline at end of file
diff --git a/modules/ppcp-axo/extensions.php b/modules/ppcp-axo/extensions.php
index 8d8bf4378..636aee38e 100644
--- a/modules/ppcp-axo/extensions.php
+++ b/modules/ppcp-axo/extensions.php
@@ -83,7 +83,7 @@ return array(
->rule()
->condition_element( 'axo_enabled', '1' )
->action_visible( 'axo_gateway_title' )
- ->action_visible( 'axo_checkout_config_notice' )
+ ->action_visible( 'axo_main_notice' )
->action_visible( 'axo_privacy' )
->action_visible( 'axo_name_on_card' )
->action_visible( 'axo_style_heading' )
@@ -114,9 +114,17 @@ return array(
),
'classes' => array( 'ppcp-valign-label-middle', 'ppcp-align-label-center' ),
),
- 'axo_checkout_config_notice' => array(
+ 'axo_main_notice' => array(
'heading' => '',
- 'html' => $container->get( 'axo.checkout-config-notice' ),
+ 'html' => implode(
+ '',
+ array(
+ $container->get( 'axo.settings-conflict-notice' ),
+ $container->get( 'axo.shipping-config-notice' ),
+ $container->get( 'axo.checkout-config-notice' ),
+ $container->get( 'axo.incompatible-plugins-notice' ),
+ )
+ ),
'type' => 'ppcp-html',
'classes' => array( 'ppcp-field-indent' ),
'class' => array(),
diff --git a/modules/ppcp-axo/resources/js/AxoManager.js b/modules/ppcp-axo/resources/js/AxoManager.js
index b0837bcd6..34b8d24c5 100644
--- a/modules/ppcp-axo/resources/js/AxoManager.js
+++ b/modules/ppcp-axo/resources/js/AxoManager.js
@@ -709,6 +709,8 @@ class AxoManager {
}`
);
+ this.emailInput.value = this.stripSpaces( this.emailInput.value );
+
this.$( this.el.paymentContainer.selector + '-detail' ).html( '' );
this.$( this.el.paymentContainer.selector + '-form' ).html( '' );
@@ -1134,6 +1136,10 @@ class AxoManager {
return emailPattern.test( value );
}
+ stripSpaces( str ) {
+ return str.replace( /\s+/g, '' );
+ }
+
validateEmail( billingEmail ) {
const billingEmailSelector = document.querySelector( billingEmail );
const value = document.querySelector( billingEmail + ' input' ).value;
diff --git a/modules/ppcp-axo/resources/js/Helper/Debug.js b/modules/ppcp-axo/resources/js/Helper/Debug.js
index 84cda012c..6345ee935 100644
--- a/modules/ppcp-axo/resources/js/Helper/Debug.js
+++ b/modules/ppcp-axo/resources/js/Helper/Debug.js
@@ -1,7 +1,19 @@
export function log( message, level = 'info' ) {
const wpDebug = window.wc_ppcp_axo?.wp_debug;
const endpoint = window.wc_ppcp_axo?.ajax?.frontend_logger?.endpoint;
- if ( ! endpoint ) {
+ const loggingEnabled = window.wc_ppcp_axo?.logging_enabled;
+
+ if ( wpDebug ) {
+ switch ( level ) {
+ case 'error':
+ console.error( `[AXO] ${ message }` );
+ break;
+ default:
+ console.log( `[AXO] ${ message }` );
+ }
+ }
+
+ if ( ! endpoint || ! loggingEnabled ) {
return;
}
@@ -15,15 +27,5 @@ export function log( message, level = 'info' ) {
level,
},
} ),
- } ).then( () => {
- if ( wpDebug ) {
- switch ( level ) {
- case 'error':
- console.error( `[AXO] ${ message }` );
- break;
- default:
- console.log( `[AXO] ${ message }` );
- }
- }
} );
}
diff --git a/modules/ppcp-axo/services.php b/modules/ppcp-axo/services.php
index 9d4e6d5fe..5b468835f 100644
--- a/modules/ppcp-axo/services.php
+++ b/modules/ppcp-axo/services.php
@@ -12,10 +12,10 @@ namespace WooCommerce\PayPalCommerce\Axo;
use WooCommerce\PayPalCommerce\Axo\Assets\AxoManager;
use WooCommerce\PayPalCommerce\Axo\Gateway\AxoGateway;
use WooCommerce\PayPalCommerce\Axo\Helper\ApmApplies;
+use WooCommerce\PayPalCommerce\Axo\Helper\SettingsNoticeGenerator;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
-use WooCommerce\PayPalCommerce\WcGateway\Helper\CartCheckoutDetector;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
return array(
@@ -25,7 +25,7 @@ return array(
$apm_applies = $container->get( 'axo.helpers.apm-applies' );
assert( $apm_applies instanceof ApmApplies );
- return $apm_applies->for_country_currency() && $apm_applies->for_settings();
+ return $apm_applies->for_country_currency();
},
'axo.helpers.apm-applies' => static function ( ContainerInterface $container ) : ApmApplies {
@@ -36,6 +36,10 @@ return array(
);
},
+ 'axo.helpers.settings-notice-generator' => static function ( ContainerInterface $container ) : SettingsNoticeGenerator {
+ return new SettingsNoticeGenerator();
+ },
+
// If AXO is configured and onboarded.
'axo.available' => static function ( ContainerInterface $container ): bool {
return true;
@@ -159,48 +163,35 @@ return array(
);
},
+ 'axo.settings-conflict-notice' => static function ( ContainerInterface $container ) : string {
+ $settings_notice_generator = $container->get( 'axo.helpers.settings-notice-generator' );
+ assert( $settings_notice_generator instanceof SettingsNoticeGenerator );
+
+ $settings = $container->get( 'wcgateway.settings' );
+ assert( $settings instanceof Settings );
+
+ return $settings_notice_generator->generate_settings_conflict_notice( $settings );
+ },
+
'axo.checkout-config-notice' => static function ( ContainerInterface $container ) : string {
- $checkout_page_link = esc_url( get_edit_post_link( wc_get_page_id( 'checkout' ) ) ?? '' );
- $block_checkout_docs_link = __(
- 'https://woocommerce.com/document/cart-checkout-blocks-status/#reverting-to-the-cart-and-checkout-shortcodes',
- 'woocommerce-paypal-payments'
- );
+ $settings_notice_generator = $container->get( 'axo.helpers.settings-notice-generator' );
+ assert( $settings_notice_generator instanceof SettingsNoticeGenerator );
- if ( CartCheckoutDetector::has_elementor_checkout() ) {
- $notice_content = sprintf(
- /* translators: %1$s: URL to the Checkout edit page. %2$s: URL to the block checkout docs. */
- __(
- 'Warning: The Checkout page of your store currently uses the Elementor Checkout widget
. To enable Fastlane and accelerate payments, the page must include either the Classic Checkout
or the [woocommerce_checkout]
shortcode. See this page for instructions on how to switch to the classic layout.',
- 'woocommerce-paypal-payments'
- ),
- esc_url( $checkout_page_link ),
- esc_url( $block_checkout_docs_link )
- );
- } elseif ( CartCheckoutDetector::has_block_checkout() ) {
- $notice_content = sprintf(
- /* translators: %1$s: URL to the Checkout edit page. %2$s: URL to the block checkout docs. */
- __(
- 'Warning: The Checkout page of your store currently uses the WooCommerce Checkout
block. To enable Fastlane and accelerate payments, the page must include either the Classic Checkout
or the [woocommerce_checkout]
shortcode. See this page for instructions on how to switch to the classic layout.',
- 'woocommerce-paypal-payments'
- ),
- esc_url( $checkout_page_link ),
- esc_url( $block_checkout_docs_link )
- );
- } elseif ( ! CartCheckoutDetector::has_classic_checkout() ) {
- $notice_content = sprintf(
- /* translators: %1$s: URL to the Checkout edit page. %2$s: URL to the block checkout docs. */
- __(
- 'Warning: The Checkout page of your store does not seem to be properly configured or uses an incompatible third-party Checkout
solution. To enable Fastlane and accelerate payments, the page must include either the Classic Checkout
or the [woocommerce_checkout]
shortcode. See this page for instructions on how to switch to the classic layout.',
- 'woocommerce-paypal-payments'
- ),
- esc_url( $checkout_page_link ),
- esc_url( $block_checkout_docs_link )
- );
- } else {
- return '';
- }
+ return $settings_notice_generator->generate_checkout_notice();
+ },
- return '
' . $notice_content . '
' . $notice_content . '
%2$s
', + $is_error ? 'ppcp-notice-error' : '', + $message + ); + } + + /** + * Generates the checkout notice. + * + * @return string + */ + public function generate_checkout_notice(): string { + $checkout_page_link = esc_url( get_edit_post_link( wc_get_page_id( 'checkout' ) ) ?? '' ); + $block_checkout_docs_link = __( + 'https://woocommerce.com/document/cart-checkout-blocks-status/#reverting-to-the-cart-and-checkout-shortcodes', + 'woocommerce-paypal-payments' + ); + + $notice_content = ''; + + if ( CartCheckoutDetector::has_elementor_checkout() ) { + $notice_content = sprintf( + /* translators: %1$s: URL to the Checkout edit page. %2$s: URL to the block checkout docs. */ + __( + 'Warning: The Checkout page of your store currently uses theElementor Checkout widget
. To enable Fastlane and accelerate payments, the page must include either the Classic Checkout
or the [woocommerce_checkout]
shortcode. See this page for instructions on how to switch to the classic layout.',
+ 'woocommerce-paypal-payments'
+ ),
+ esc_url( $checkout_page_link ),
+ esc_url( $block_checkout_docs_link )
+ );
+ } elseif ( CartCheckoutDetector::has_block_checkout() ) {
+ $notice_content = sprintf(
+ /* translators: %1$s: URL to the Checkout edit page. %2$s: URL to the block checkout docs. */
+ __(
+ 'Warning: The Checkout page of your store currently uses the WooCommerce Checkout
block. To enable Fastlane and accelerate payments, the page must include either the Classic Checkout
or the [woocommerce_checkout]
shortcode. See this page for instructions on how to switch to the classic layout.',
+ 'woocommerce-paypal-payments'
+ ),
+ esc_url( $checkout_page_link ),
+ esc_url( $block_checkout_docs_link )
+ );
+ } elseif ( ! CartCheckoutDetector::has_classic_checkout() ) {
+ $notice_content = sprintf(
+ /* translators: %1$s: URL to the Checkout edit page. %2$s: URL to the block checkout docs. */
+ __(
+ 'Warning: The Checkout page of your store does not seem to be properly configured or uses an incompatible third-party Checkout
solution. To enable Fastlane and accelerate payments, the page must include either the Classic Checkout
or the [woocommerce_checkout]
shortcode. See this page for instructions on how to switch to the classic layout.',
+ 'woocommerce-paypal-payments'
+ ),
+ esc_url( $checkout_page_link ),
+ esc_url( $block_checkout_docs_link )
+ );
+ }
+
+ return $notice_content ? '' . $notice_content . '
Force shipping to the customer billing address
. To enable Fastlane and accelerate payments, the shipping destination must be configured either to Default to customer shipping address
or Default to customer billing address
so buyers can set separate billing and shipping details.',
+ 'woocommerce-paypal-payments'
+ ),
+ esc_url( $shipping_settings_link )
+ );
+ }
+
+ return $notice_content ? '' . $notice_content . '
' . $notice_content . '