- This topic has 11 replies, 2 voices, and was last updated 2 years, 4 months ago by Elvin.
-
AuthorPosts
-
June 26, 2019 at 8:29 pm #942461Pedro
Hello! I would like to change the text of the “add to cart” button for variable products.
I see that Generatepress places the text “Select options”, instead of “Add to cart” when a product has variations.
How can I do it?
Thank you!
June 26, 2019 at 8:59 pm #942473LeoStaffCustomer SupportHi there,
I believe the first 2 snippets are what you are after:
https://metorik.com/blog/change-the-add-to-cart-text-in-woocommerceJune 26, 2019 at 9:15 pm #942484PedroHi leo! Thanks for answering.
I think I was not specific, I want to change the text to sticky add to cart for variable products.
Since it currently shows “Select options”, and I would like it to say “Add to cart”
I’m sorry I did not say it was the sticky add to cart.
June 27, 2019 at 8:21 am #943018TomLead DeveloperLead DeveloperThe link Leo posted has the answer.
For example:
add_filter( 'woocommerce_product_add_to_cart_text', function( $text ) { global $product; $product_type = $product->product_type; if ( 'variable' === $product_type ) { $text = 'Add to cart'; } return $text; } );
June 27, 2019 at 5:41 pm #943382PedroThank so you mucho Leo and Tom!! You have the best support in the world!!
June 28, 2019 at 6:49 am #943910TomLead DeveloperLead DeveloperGlad we could help 🙂
July 18, 2019 at 10:34 am #961370ChristineHi, I am Looking for similar thing. On my website homepage (https://staging.gartersandco.com.au/)
here is a woocommerce product slider and there SELECT OPTIONS I want to change to BUY NOW.
I tried the snippets from https://metorik.com/blog/change-the-add-to-cart-text-in-woocommerce but these are not working.
function woo_custom_product_add_to_cart_text() { return __( 'Buy Now', 'woocommerce' ); };
This is changing the text only for 2 products in the slider. Please help.
July 18, 2019 at 12:02 pm #961418LeoStaffCustomer SupportAny chance you can open a new topic for your question?
Also I don’t see Select Options in the product slider in the home page.
Thanks 🙂
December 22, 2021 at 2:22 pm #2057114ÉvaHi,
I would like to rename the button on the archive pages to “Buy now”. For the single products a plugin to make the checkout a onestep process takes care of it, however 2 products are for free, hence it makes no sense naming their button “Buy now”, instead of “Download”. Unfortunately, I wasn’t successful in adjusting the codes offered via the link.
Your help would be greatly appreciated.Thank you.
Regards
ÉvaDecember 22, 2021 at 5:49 pm #2057216ElvinStaffCustomer SupportHi Éva
Try this:
add_filter( 'woocommerce_product_add_to_cart_text', function( $text ) { global $product; if ( $product->is_type( 'variable' ) ) { $prices = $product->get_variation_prices( true ); $min_price = current( $prices['price'] ); if ( 0 == $min_price ) { $max_price = end( $prices['price'] ); $min_reg_price = current( $prices['regular_price'] ); $max_reg_price = end( $prices['regular_price'] ); if ( $min_price !== $max_price ) { $text = 'Download'; } elseif ( $product->is_on_sale() && $min_reg_price === $max_reg_price ) { $text = 'Download'; } else { $text = 'Download'; } } } elseif ( 0 == $product->get_price() ) { $text = 'Download'; } return $text; } );
December 23, 2021 at 2:03 am #2057425ÉvaHi Elvin,
worked like a charm! Thank you so much and merry christmas.
Regards
ÉvaDecember 27, 2021 at 9:57 pm #2061323ElvinStaffCustomer SupportNo problem. 😀
-
AuthorPosts
- You must be logged in to reply to this topic.