• Resolved crowds90

    (@crowds90)


    Hi,

    Is there a function to change the “Add To Cart” to a custom text like Add To Bag

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support Juan Coronel

    (@juaancmendez)

    Hello there,
    we hope you’re doing well!

    In order to achieve what you need, add the following code in the functions.php file of your active child theme:

    if ( ! function_exists( 'yith_wcwl_change_add_to_cart_text' ) ) {
        function yith_wcwl_change_add_to_cart_text() {
            $jquery = 'jQuery( function( $ ) {
                $( ".wishlist_table td.product-add-to-cart a.add_to_cart_button" ).text( "Add to bag" );
                
            });';
            wp_add_inline_script( 'jquery-yith-wcwl', $jquery );
            wp_add_inline_script( 'jquery-yith-wcwl-user', $jquery );
        }
        add_action( 'wp_enqueue_scripts', 'yith_wcwl_change_add_to_cart_text', 999 );
    }

    Check it out and tell us if it works well for you, please.

    Have a nice day!

    Thread Starter crowds90

    (@crowds90)

    Thank you!

    Thread Starter crowds90

    (@crowds90)

    Hi @juaancmendez,

    Just following up.

    With the code, it changes all the carts in the wishlist to add to bag. (Screenshot 1)

    Is there a way to have the ‘add to bag’ and keep the ‘select options’ if the customer has not chosen the variations. (Screenshot 2)

    Screenshot 1
    Screenshot 2

    • This reply was modified 2 years ago by crowds90.
    Plugin Support Juan Coronel

    (@juaancmendez)

    Hello there,

    In order to fix that, replace the previous code with this new one:

    if ( ! function_exists( 'yith_wcwl_change_add_to_cart_text' ) ) {
        function yith_wcwl_change_add_to_cart_text() {
            $jquery = 'jQuery( function( $ ) {
                $( ".wishlist_table td.product-add-to-cart a.add_to_cart_button.product_type_simple" ).text( "Add to bag" );
                
            });';
            wp_add_inline_script( 'jquery-yith-wcwl', $jquery );
            wp_add_inline_script( 'jquery-yith-wcwl-user', $jquery );
        }
        add_action( 'wp_enqueue_scripts', 'yith_wcwl_change_add_to_cart_text', 999 );
    }

    Check it out and tell us if it works well for you, please.

    Best regards.

    Thread Starter crowds90

    (@crowds90)

    Hi @juaancmendez,

    I tried but it wasn’t changing the ‘Add to Cart’ to ‘Add to Bag’

    Plugin Support Juan Coronel

    (@juaancmendez)

    Hello there,

    In our installation the code works correctly. Could you share the link to your site? Maybe the HTML of your page differs from ours.

    We will be attentive to your response.

    Best regards.

    Thread Starter crowds90

    (@crowds90)

    Here is the website

    Link Here

    Plugin Support Juan Coronel

    (@juaancmendez)

    Hello there,

    Please replace the previous code with this new one:

    if ( ! function_exists( 'yith_wcwl_change_add_to_cart_text' ) ) {
        function yith_wcwl_change_add_to_cart_text() {
            $jquery = 'jQuery( function( $ ) {            
    $( ".wishlist_table td.product-add-to-cart a.add_to_cart_button.product_type_simple, .wishlist_table td.product-add-to-cart a.add_to_cart_button.product_type_variation" ).text( "Add to bag" );            
            });';
            wp_add_inline_script( 'jquery-yith-wcwl', $jquery );
            wp_add_inline_script( 'jquery-yith-wcwl-user', $jquery );
        }
        add_action( 'wp_enqueue_scripts', 'yith_wcwl_change_add_to_cart_text', 999 );
    }

    Let us know any news.

    Have a nice day!

    Thread Starter crowds90

    (@crowds90)

    Perfect! Thank you again

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Change Add to Cart Name’ is closed to new replies.