Hi @starmate,
Thanks for the nice words.
Yes, there is a function available in the plugin that you can use to detect whether the current request is for the checkout page main document or for fragment updates when updating parts of the checkout page.
The code below will return true
when the current request if for a checkout page or fragments update, but it will return false
for any other page or for other endpoints on the checkout page which are not currently optimized by Fluid Checkout:
// First check whether Fluid Checkout class is available,
// then check whether request is for the checkout page
// or a fragments update request.
if ( class_exists( 'FluidCheckout_Steps' ) && FluidCheckout_Steps::instance()->is_checkout_page_or_fragment() ) {
// DO SOMETHING
}
It is also possible to detect if Fluid Checkout is active using Javascript or CSS, depending on what you want to accomplish.
Fluid Checkout will add class has-fluid-checkout
to the document.body
element on the checkout page so that you can use them to detect if the plugin is active. The plugin will add similar classes to the document.body
element for most of its features.
Javascript
// Check whether Fluid Checkout is activated in Javascript.
if ( document.body.classList.contains( 'has-fluid-checkout' ) {
// DO SOMETHING
}
CSS
/**
* Check whether the Fluid Checkout is activated in CSS.
* Replace
<your-selector>
with any valid CSS selector
* to target the elements you want to apply custom styles to.
*/
body.has-fluid-checkout <your-selector> {
/* APPLY STYLES */
}
I hope this helps.
Best,
Diego.