Last active
January 14, 2021 09:42
-
-
Save kontikidigital/b92dbf2ebde2bc5e54e8967f9bf7d149 to your computer and use it in GitHub Desktop.
WooCommerce: Change Select Options Button Text for variable products
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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->get_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' ); | |
} | |
} |
You need to add this code in your child theme to functions.php
This is a lifesaver - thank you!
Brilliant! Thank you!
problem get type , please use
$product_type = $product->get_type();
Perfect !
This is working beautifully, thank you!
I have woocommerce Combo Offer product, and this code is not changing text for combo product! pls help
Thank you. Perfect!
problem get type , please use
$product_type = $product->get_type();
Thanks, I've updated this gist including your suggestion.
I have woocommerce Combo Offer product, and this code is not changing text for combo product! pls help
Sorry, I don't know Combo Offer product, maybe this plugin is modifying woocommerce_product_add_to_cart_text filter or something like that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do i add this to the file or is this code there and the text just needs to edited? Where do I find this file?