How to Change Add to Cart Text In WooCommerce

Nên đọc

Making a sales wordpress website using woocommerce plugin is chosen by most of you because it is full of features of an online sales page today and does not need to know the code, just install a few simple steps that you have a full-featured sales website.

But one of woocommerce’s defaults is the “add to cart” button, which will not suit the needs of use, usually you want to modify the word “add to cart” to the words “Buy”, “Order now”, “Buy now”… Or any word at my disposal.

We will then instruct you to add the code to change the “add to cart” button in Woocommerce.

Open the WordPress admin, go to Appearance > Theme File Edit. You should edit in the child theme, it also has a file function.php. Avoiding new updates, all code is lost.

Find and open file functions.php add the bottom code at the end of the function.php

Save the changes and check your website.

// To change add to cart text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' ); 
function woocommerce_custom_single_add_to_cart_text() {
    return __( 'Mua ngay', 'woocommerce' ); 
}
// To change add to cart text on product archives(Collection) page
add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );  
function woocommerce_custom_product_add_to_cart_text() {
    return __( 'Mua ngay', 'woocommerce' );
}

Change the “Buy Now” text to a word that you feel is appropriate.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img
Tin mới

How to change PHP Version in cPanel hosting

Changing php version to match the code of the website is very necessary, sometimes your website requires a high...
- Advertisement -spot_img

More Articles Like This