diff --git a/modules/ppcp-axo/extensions.php b/modules/ppcp-axo/extensions.php index e81176244..09b590fd7 100644 --- a/modules/ppcp-axo/extensions.php +++ b/modules/ppcp-axo/extensions.php @@ -9,6 +9,7 @@ declare(strict_types=1); namespace WooCommerce\PayPalCommerce\Axo; +use WooCommerce\PayPalCommerce\Axo\Helper\NoticeRenderer; use WooCommerce\PayPalCommerce\Axo\Helper\PropertiesDictionary; use WooCommerce\PayPalCommerce\Onboarding\State; use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; @@ -82,6 +83,7 @@ return array( ->rule() ->condition_element( 'axo_enabled', '1' ) ->action_visible( 'axo_gateway_title' ) + ->action_visible( 'axo_checkout_config_notice' ) ->action_visible( 'axo_privacy' ) ->action_visible( 'axo_name_on_card' ) ->action_visible( 'axo_style_heading' ) @@ -112,6 +114,18 @@ return array( ), 'classes' => array( 'ppcp-valign-label-middle', 'ppcp-align-label-center' ), ), + 'axo_checkout_config_notice' => array( + 'heading' => '', + 'html' => $container->get( 'axo.checkout-config-notice' ), + 'type' => 'ppcp-html', + 'classes' => array( 'ppcp-field-indent' ), + 'class' => array(), + 'screens' => array( + State::STATE_ONBOARDED, + ), + 'requirements' => array( 'dcc', 'axo' ), + 'gateway' => array( 'dcc', 'axo' ), + ), 'axo_gateway_title' => array( 'title' => __( 'Gateway Title', 'woocommerce-paypal-payments' ), 'type' => 'text', diff --git a/modules/ppcp-axo/services.php b/modules/ppcp-axo/services.php index e7a450692..44253f22d 100644 --- a/modules/ppcp-axo/services.php +++ b/modules/ppcp-axo/services.php @@ -13,6 +13,7 @@ use WooCommerce\PayPalCommerce\Axo\Assets\AxoManager; use WooCommerce\PayPalCommerce\Axo\Gateway\AxoGateway; use WooCommerce\PayPalCommerce\Axo\Helper\ApmApplies; use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; +use WooCommerce\PayPalCommerce\WcGateway\Helper\CartCheckoutDetector; return array( @@ -149,4 +150,47 @@ return array( ); }, + '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' + ); + + 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 '

' . $notice_content . '

'; + }, ); diff --git a/modules/ppcp-wc-gateway/resources/css/common.scss b/modules/ppcp-wc-gateway/resources/css/common.scss index 1d074ee34..1345cb810 100644 --- a/modules/ppcp-wc-gateway/resources/css/common.scss +++ b/modules/ppcp-wc-gateway/resources/css/common.scss @@ -56,6 +56,25 @@ $background-ident-color: #fbfbfb; } } +.ppcp-notice { + background: #fff; + border: 1px solid #c3c4c7; + border-left-width: 4px; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04); + margin: 5px 15px 2px; + padding: 1px 12px; +} + +.ppcp-notice-warning { + border-left-color: #dba617; + + .highlight { + background: transparent; + color: #dba617; + font-weight: 600; + } +} + // Box indented fields. @media screen and (min-width: 800px) { .ppcp-settings-field { @@ -77,6 +96,18 @@ $background-ident-color: #fbfbfb; th, &.ppcp-settings-field-heading td { padding-left: 40px; + padding-right: 40px; + } + + .ppcp-notice { + margin-left: 40px; + margin-right: 10px; + padding: 1px 12px; + + p { + margin: .5em 0; + padding: 2px; + } } th, td { diff --git a/modules/ppcp-wc-gateway/src/Helper/CartCheckoutDetector.php b/modules/ppcp-wc-gateway/src/Helper/CartCheckoutDetector.php new file mode 100644 index 000000000..176bc05b2 --- /dev/null +++ b/modules/ppcp-wc-gateway/src/Helper/CartCheckoutDetector.php @@ -0,0 +1,129 @@ +%s', + esc_attr( implode( ' ', $config['classes'] ) ), + $config['html'] + ); + + return $html; + } + /** * Renders the table row. * diff --git a/modules/ppcp-wc-gateway/src/WCGatewayModule.php b/modules/ppcp-wc-gateway/src/WCGatewayModule.php index 8e765a8e9..19f67ef53 100644 --- a/modules/ppcp-wc-gateway/src/WCGatewayModule.php +++ b/modules/ppcp-wc-gateway/src/WCGatewayModule.php @@ -627,6 +627,7 @@ class WCGatewayModule implements ModuleInterface { $field = $renderer->render_password( $field, $key, $args, $value ); $field = $renderer->render_heading( $field, $key, $args, $value ); $field = $renderer->render_table( $field, $key, $args, $value ); + $field = $renderer->render_html( $field, $key, $args, $value ); return $field; }, 10,