From 651549dbb01c2db35723ca30e7eceb4850dc9995 Mon Sep 17 00:00:00 2001 From: George Burduli Date: Tue, 16 Jul 2024 15:10:09 +0400 Subject: [PATCH] Display notice if Checkout Blocks is not active --- .../ppcp-wc-gateway/resources/css/common.scss | 8 +++++ modules/ppcp-wc-gateway/services.php | 30 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/modules/ppcp-wc-gateway/resources/css/common.scss b/modules/ppcp-wc-gateway/resources/css/common.scss index b694547c8..7a65a701c 100644 --- a/modules/ppcp-wc-gateway/resources/css/common.scss +++ b/modules/ppcp-wc-gateway/resources/css/common.scss @@ -82,6 +82,14 @@ $background-ident-color: #fbfbfb; } } +.ppcp-notice-success { + border-left-color: #00a32a; + + .highlight { + color: #00a32a; + } +} + .ppcp-notice-warning { border-left-color: #dba617; diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index f0d848216..45a93e346 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -26,6 +26,7 @@ use WooCommerce\PayPalCommerce\Onboarding\State; use WooCommerce\PayPalCommerce\WcGateway\Admin\RenderReauthorizeAction; use WooCommerce\PayPalCommerce\WcGateway\Endpoint\CaptureCardPayment; use WooCommerce\PayPalCommerce\WcGateway\Endpoint\RefreshFeatureStatusEndpoint; +use WooCommerce\PayPalCommerce\WcGateway\Helper\CartCheckoutDetector; use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper; use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; use WooCommerce\PayPalCommerce\WcGateway\Admin\FeesRenderer; @@ -292,6 +293,24 @@ return array( static function ( ContainerInterface $container ): AuthorizeOrderActionNotice { return new AuthorizeOrderActionNotice(); }, + 'wcgateway.notice.checkout-blocks' => + static function ( ContainerInterface $container ): string { + $instructions_link = 'https://woocommerce.com/document/cart-checkout-blocks-status/#using-the-cart-and-checkout-blocks'; + if ( ! CartCheckoutDetector::has_block_checkout() ) { + $notice_content = sprintf( + /* translators: %1$s: URL to the instructions page. */ + __( + 'Your store\'s checkout page currently uses a classic checkout layout or a custom checkout widget. Advanced Card Processing now also supports the new & improved Checkout block. See this page for instructions on upgrading to the new Checkout layout.', + 'woocommerce-paypal-payments' + ), + esc_url( $instructions_link ) + ); + } else { + return ''; + } + + return '

' . $notice_content . '

'; + }, 'wcgateway.settings.sections-renderer' => static function ( ContainerInterface $container ): SectionsRenderer { return new SectionsRenderer( $container->get( 'wcgateway.current-ppcp-settings-page-id' ), @@ -533,6 +552,17 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), + 'dcc_block_checkout_notice' => array( + 'heading' => '', + 'html' => $container->get( 'wcgateway.notice.checkout-blocks' ), + 'type' => 'ppcp-html', + 'classes' => array(), + 'screens' => array( + State::STATE_ONBOARDED, + ), + 'requirements' => array( 'dcc' ), + 'gateway' => 'dcc', + ), 'dcc_enabled' => array( 'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ), 'desc_tip' => true,