How to identify in the backend if the store is using Checkout blocks [classic_checkout] or WooCommerce checkout with shortcode [woocommerce_checkout].
I’m testing a payment gateway and I use enqueue_script to add the JS to the frontend. What is the best way to validate whether a store is using the Blocks-compatible [classic_checkout] block or not, so that scripts can only be queued when necessary?
2
Answers
I finally found the way via
has_block_in_page( $page, $block_name )
function located in WC_Blocks_Utils Class. You can use it for Checkout as follows:For cart page, you can use:
Tested and works
I tried this approach: