Untitled

 avatar
unknown
plain_text
2 years ago
1.8 kB
5
Indexable
function custom_text_change_script() {
    if ( is_cart() ) { ?>
        <style>
            .loader-container {
                position: fixed;
                top: 50%;
                left: 0;
                width: 100%;
                height: 6px;
                background: #ccc;
                z-index: 9999;
            }

            .loader-bar {
                width: 0;
                height: 100%;
                background: #555; /* Grey color */
                transition: width 0.5s ease-in-out;
            }
        </style>
        <div class="loader-container">
            <div class="loader-bar"></div>
        </div>
        <script type="text/javascript">
            // Hide the product name field initially
            jQuery(document).ready(function($) {
                $('.woocommerce-cart-form .product-name').css('visibility', 'hidden');

                // Wait for 0.5 seconds and then smoothly reveal the product name field with a transition effect
                setTimeout(function() {
                    $('.woocommerce-cart-form .product-name').css('visibility', 'visible').css('opacity', '1');
                    $('.loader-bar').css('width', '100%');
                    setTimeout(function() {
                        $('.loader-container').remove();
                    }, 500);
                }, 500);

                // Replace the text inside <strong> tags in the cart page
                $('.woocommerce-cart-form .product-name strong:contains("Inserisci la larghezza (m):")').each(function() {
                    $(this).text($(this).text().replace('Inserisci la larghezza (m):', 'Largezza:'));
                });
            });
        </script>
    <?php }
}
add_action('wp_head', 'custom_text_change_script');
Editor is loading...