Change add to cart button text in WooCommerce
Change the add to cart text on single product pages:
Add the below code to your functions.php file
1 2 3 4 5 6 7 |
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' ); } |
Change the add to cart text on product archives page:
Add the below code to your functions.php file
1 2 3 4 5 6 7 |
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' ); } |
Change the add to cart text on product archives by product types:
Add the below code to your functions.php file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<?php add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' ); /** * custom_woocommerce_template_loop_add_to_cart */ function custom_woocommerce_product_add_to_cart_text() { global $product; $product_type = $product->product_type; switch ( $product_type ) { case 'external': return __( 'Buy product', 'woocommerce' ); break; case 'grouped': return __( 'View products', 'woocommerce' ); break; case 'simple': return __( 'Add to cart', 'woocommerce' ); break; case 'variable': return __( 'Select options', 'woocommerce' ); break; default: return __( 'Read more', 'woocommerce' ); } } |
Video Tutorial:
Subscribe to our Youtube Channel: Get notification for our Latest Videos
Reference: WooCommerce