Home Forums WoodMart support forum How to change text of "add to cart" button

How to change text of "add to cart" button

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #132523

    sanchitgoyal
    Participant

    Hello

    How can I change the text on add to cart button and display something else? Regards.

    http://prntscr.com/oehbpr

    #132534

    Hello,

    You can rewrite all theme and plugin texts via PO file in WordPress. Here is a video tutorial that should help you rewrite your website texts with a Loco Translate plugin https://www.youtube.com/watch?v=D3NsDdMzsls&list=PLMw6W4rAaOgKKv0oexGHzpWBg1imvrval&index=3

    Best Regards

    #132537

    sanchitgoyal
    Participant

    Hello

    Thanks but I am not looking to translate all website text. I am only looking to change the text from “add to cart” to “take My Money”. I did a google search and found some easy code such as

    add_filter( 'add_to_cart_text', 'woo_custom_single_add_to_cart_text' );                // < 2.1
    add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_single_add_to_cart_text' );  // 2.1 +
      
    function woo_custom_single_add_to_cart_text() {
      
        return __( 'My Button Text', 'woocommerce' );
      
    }

    But I dont know if they work now as they are a bit old.

    Isnt there a similar code to change the text without having to install the loco translate plugin? Regards.

    #132544

    Hello,

    We have not tested the code and do not guarantee smooth working. You may try on your own responsibility. Please note, each time you update the theme, you will need to change it in the code that is why I recommend Loco

    Best Regards

    #132579

    sanchitgoyal
    Participant

    Hello

    I added the following code to the child theme of the website. Seems to be working great.

    /**
    -----------------------------------------------------------------------------
     Change add to cart text
    -----------------------------------------------------------------------------
    
    */
    
    add_filter( 'woocommerce_product_single_add_to_cart_text' , 'woo_custom_cart_button_text' );
    
    function woo_custom_cart_button_text() {
    return __('Take My Money!' , 'woocommerce');
    }
    
    #132598

    That is fine. it would be helpful for those who do not want to install Loco. If you have any questions please feel free to contact us.

    Best Regards

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘How to change text of "add to cart" button’ is closed to new replies.