How to change Add to cart text as my own text in W

2019-02-20 19:13发布

问题:

I am using Woocommerce V2.1.2 in Latest version of wordpress. I have googled, they have given a solution to change in frontend. But I need to change from backend.

Kindly suggest any idea's to fix the above issue.

回答1:

This will change Add to cart button text in woocommerce...

I am not sure but this will help you in < 2.1 versions...I don't know about 2.1+

Add this code into your theme's functions.php file.

add_filter( 'add_to_cart_text', 'woo_custom_cart_button_text' );
//For Single Product Page.
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' );
//For Archives Product Page.
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_cart_button_text' );
function woo_custom_cart_button_text()
{
    return __( 'My Button Text', 'woocommerce' );
}


回答2:

add_filter( 'add_to_cart_text', 'woo_custom_cart_button_text' );                        
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_cart_button_text' );
add_filter('woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text');

function woo_custom_cart_button_text() {
    return __( 'Buy Now', 'woocommerce' );
}