File tree Expand file tree Collapse file tree 5 files changed +61
-4
lines changed
Expand file tree Collapse file tree 5 files changed +61
-4
lines changed Original file line number Diff line number Diff line change 1010 font-size : 1em ;
1111 height : 3.125em ;
1212 line-height : 1 ;
13- margin : 0 0 0.75em 0 ;
1413 min-height : 0 ;
1514 padding : 0 ;
1615 width : 100% ;
6867
6968/* Label Container */
7069.monei-label-container {
71- display : flex;
72- align-items : center;
73- gap : 1em ;
70+ display : block;
7471}
7572
7673.monei-text {
Original file line number Diff line number Diff line change 1212use WC_Admin_Settings ;
1313use WC_Monei_Logger ;
1414use WC_Payment_Gateway ;
15+ use WC_Blocks_Utils ;
1516
1617if ( ! defined ( 'ABSPATH ' ) ) {
1718 exit ;
@@ -362,6 +363,30 @@ public function isBlockCheckout() {
362363 return ( isset ( $ _POST ['monei_is_block_checkout ' ] ) ) ? wc_clean ( wp_unslash ( $ _POST ['monei_is_block_checkout ' ] ) ) === 'yes ' : false ; // WPCS: CSRF ok.
363364 }
364365
366+ /**
367+ * Check if the checkout page is using WooCommerce Blocks.
368+ * Used for script enqueuing to differentiate between classic and blocks checkout.
369+ *
370+ * @return bool
371+ */
372+ public function is_block_checkout_page () {
373+ if ( ! is_checkout () ) {
374+ return false ;
375+ }
376+ if ( ! class_exists ( 'WC_Blocks_Utils ' ) ) {
377+ return false ;
378+ }
379+ // Check if the checkout block is present
380+ $ has_block = WC_Blocks_Utils::has_block_in_page ( wc_get_page_id ( 'checkout ' ), 'woocommerce/checkout ' );
381+
382+ // Additional check: see if the traditional checkout shortcode is present
383+ $ checkout_page = get_post ( wc_get_page_id ( 'checkout ' ) );
384+ $ has_shortcode = $ checkout_page ? has_shortcode ( $ checkout_page ->post_content , 'woocommerce_checkout ' ) : false ;
385+
386+ // If the block is present and the shortcode is not, we can be more confident it's a block checkout
387+ return $ has_block && ! $ has_shortcode ;
388+ }
389+
365390 /**
366391 * Frontend MONEI generated token.
367392 *
Original file line number Diff line number Diff line change 1010use WC_Order ;
1111use WC_Payment_Tokens ;
1212use WC_Monei_Logger ;
13+ use WC_Blocks_Utils ;
1314
1415if ( ! defined ( 'ABSPATH ' ) ) {
1516 exit ;
@@ -292,6 +293,30 @@ public function isBlockCheckout() {
292293 return ( isset ( $ _POST ['monei_is_block_checkout ' ] ) ) ? wc_clean ( wp_unslash ( $ _POST ['monei_is_block_checkout ' ] ) ) === 'yes ' : false ; // WPCS: CSRF ok.
293294 }
294295
296+ /**
297+ * Check if the checkout page is using WooCommerce Blocks.
298+ * Used for script enqueuing to differentiate between classic and blocks checkout.
299+ *
300+ * @return bool
301+ */
302+ public function is_block_checkout_page () {
303+ if ( ! is_checkout () ) {
304+ return false ;
305+ }
306+ if ( ! class_exists ( 'WC_Blocks_Utils ' ) ) {
307+ return false ;
308+ }
309+ // Check if the checkout block is present
310+ $ has_block = WC_Blocks_Utils::has_block_in_page ( wc_get_page_id ( 'checkout ' ), 'woocommerce/checkout ' );
311+
312+ // Additional check: see if the traditional checkout shortcode is present
313+ $ checkout_page = get_post ( wc_get_page_id ( 'checkout ' ) );
314+ $ has_shortcode = $ checkout_page ? has_shortcode ( $ checkout_page ->post_content , 'woocommerce_checkout ' ) : false ;
315+
316+ // If the block is present and the shortcode is not, we can be more confident it's a block checkout
317+ return $ has_block && ! $ has_shortcode ;
318+ }
319+
295320 /**
296321 * Frontend MONEI cardholderName.
297322 *
Original file line number Diff line number Diff line change @@ -170,6 +170,11 @@ public function monei_scripts() {
170170 return ;
171171 }
172172
173+ // Don't load classic CSS on blocks checkout
174+ if ( $ this ->is_block_checkout_page () ) {
175+ return ;
176+ }
177+
173178 // Register and enqueue classic checkout CSS
174179 wp_register_style (
175180 'monei-classic-checkout ' ,
Original file line number Diff line number Diff line change @@ -420,6 +420,11 @@ public function monei_scripts() {
420420 return ;
421421 }
422422
423+ // Don't load classic CSS on blocks checkout
424+ if ( $ this ->is_block_checkout_page () ) {
425+ return ;
426+ }
427+
423428 // Register and enqueue classic checkout CSS
424429 wp_register_style (
425430 'monei-classic-checkout ' ,
You can’t perform that action at this time.
0 commit comments