How to change Add to cart button text in woocommerce

0
40
change woocommerce add to cart button text

How to change Add to cart button text in woocommerce

 

1. Using “Change WooCommerce Add To Cart Button Text” Plugin

WooCommerce is one of the most popular WordPress plugin and best solution for eCommerce. The button used to buy products has static text and you can not change that without getting your hands dirty with codes.

this plugin for you to change the button text the way you want to be in any language. You can even use speacial Unicode characters, HTML5 Special Characters, Font Awesome or any other icon that loads on the page from your theme or plugin and Emojis too!

This plugin helps you to change the “Add To Cart” button text to anything from a simple settings page available in wp-admin → Settings → Reading

2. Adding Custom PHP Codes

To change add to cart text on single product pages, Add these to custom-function.php file

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' );
 
}

To change add to cart text on product archives:

  1. add_filter( 'add_to_cart_text', 'woo_custom_product_add_to_cart_text' );            // < 2.1
    add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_product_add_to_cart_text' );  // 2.1 +
     
    function woo_custom_product_add_to_cart_text() {
     
        return __( 'My Button Text', 'woocommerce' );
     
    }

    (where ‘My Button Text’ is the new name of your “Add to cart” button)

  2. Save the changes and check your website. The new name of the button should show up now.

3. Adding Custom PHP Codes Example 2

Code goes in functions.php file of your active child theme (or theme). Or also in any plugin php files.

To change the Add to Cart button text for shop page you have to use woocommerce_product_add_to_cart_text filter.

Here is the code:

add_filter('woocommerce_product_add_to_cart_text', 'wh_archive_custom_cart_button_text');   // 2.1 +

function wh_archive_custom_cart_button_text()
{
    return __('+', 'woocommerce');
}

 

 

 

Related Post