Change add to cart button text on click event in Woocommerce on shop pages

11 views Asked by At

Help me please. Here I found a code that works and I need it. Maybe someone knows how to make this work on the pages of the store and product categories?

add_action( 'wp_footer', 'single_add_to_cart_event_text_replacement' );
function single_add_to_cart_event_text_replacement() {
    global $product;

    if( ! is_product() ) return; // Only single product pages
    if( $product->is_type('variable') ) return; // Not variable products
    ?>
        <script type="text/javascript">
            (function($){
                $('button.single_add_to_cart_button').click( function(){
                    $(this).text('<?php _e( "Adding...", "woocommerce" ); ?>');
                });
            })(jQuery);
        </script>
    <?php
}

I tried various options but it didn’t work out for me. So I'm asking for help

0

There are 0 answers