简体   繁体   中英

Translating add to cart woocommerce

I am trying to translate add to cart button. I have 2 code snippets from woocommerce documentation here are they:

FOR SINGLE PRODUCT - THIS ONE WORKS

add_filter( 'woocommerce_product_single_add_to_cart_text', 
'woo_custom_cart_button_text' );    // 2.1 +

function woo_custom_cart_button_text() {

    return __( 'My Button Text', 'woocommerce' );

}

FOR PRODUCT ARCHIVE - NOT WORKING?

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

function woo_archive_custom_cart_button_text() {

    return __( 'My Button Text', 'woocommerce' );

}

I dont know why this other is not working. Is there some fix. I am using DIVI wordpress theme. And also overwrote my loop archive addtocart.php so I can display quantity input. This is also snippet from woocommerce documentation.

Try use the plugin Change WooCommerce Add to Cart Text . Install it, and Activate .

Then go to wp-admin → Settings → Reading and fill your translation on Add To Cart Button Text For Single Page for Single Page and fill your translation on Add To Cart Button Text For Archive Pages for Archive Pages.

I've done this, and it's work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM