Hide the CheckoutWC Side Cart elements from any page when the Elementor editor is active

The Problem

The CheckoutWC sidecart animation popout would trigger every time I updated / published the page when the Elementor editor was active.

 

The Solution

After reaching out to the CheckoutWC support team, they kindly shared a PHP function that hides the CheckoutWC sidecart elements when the Elementor editor is active. Thank you CheckoutWC support team, it works like a charm!!

Simply add the following code to the “PHP Scripts” section within the CheckoutWC settings.

CheckoutWC > Advanced > Scripts > PHP Scripts

The Code

				
					function custom_inline_script_for_elementor() {
    // Check if we are in the admin area and return early if we are not
    if (is_admin()) {
        return;
    }

    ?>
    <script>
    (function() {
        var checkAndHide = function() {
            if (document.body.classList.contains('elementor-editor-active')) {
                var elementsToHideIds = ['cfw-side-cart-floating-button', 'cfw-side-cart-overlay', 'cfw-side-cart'];
                elementsToHideIds.forEach(function(id) {
                    var elementToHide = document.getElementById(id);
                    if (elementToHide) {
                        elementToHide.style.display = 'none';
                    }
                });
            }
        };

        // Check immediately
        checkAndHide();

        // Then check repeatedly for a few seconds
        var intervalId = setInterval(checkAndHide, 500);

        // Stop checking after 5 seconds
        setTimeout(function() {
            clearInterval(intervalId);
        }, 5000);
    })();
    </script>
    <?php
}
add_action('wp_footer', 'custom_inline_script_for_elementor');
				
			
Picture of bocivusteam

bocivusteam

Message Us

Name