Change Add to Cart Name
-
Hi,
Is there a function to change the “Add To Cart” to a custom text like Add To Bag
-
Hello there,
we hope you’re doing well!In order to achieve what you need, add the following code in the functions.php file of your active child theme:
if ( ! function_exists( 'yith_wcwl_change_add_to_cart_text' ) ) { function yith_wcwl_change_add_to_cart_text() { $jquery = 'jQuery( function( $ ) { $( ".wishlist_table td.product-add-to-cart a.add_to_cart_button" ).text( "Add to bag" ); });'; wp_add_inline_script( 'jquery-yith-wcwl', $jquery ); wp_add_inline_script( 'jquery-yith-wcwl-user', $jquery ); } add_action( 'wp_enqueue_scripts', 'yith_wcwl_change_add_to_cart_text', 999 ); }
Check it out and tell us if it works well for you, please.
Have a nice day!
Thank you!
Hi @juaancmendez,
Just following up.
With the code, it changes all the carts in the wishlist to add to bag. (Screenshot 1)
Is there a way to have the ‘add to bag’ and keep the ‘select options’ if the customer has not chosen the variations. (Screenshot 2)
- This reply was modified 1 year, 5 months ago by crowds90.
Hello there,
In order to fix that, replace the previous code with this new one:
if ( ! function_exists( 'yith_wcwl_change_add_to_cart_text' ) ) { function yith_wcwl_change_add_to_cart_text() { $jquery = 'jQuery( function( $ ) { $( ".wishlist_table td.product-add-to-cart a.add_to_cart_button.product_type_simple" ).text( "Add to bag" ); });'; wp_add_inline_script( 'jquery-yith-wcwl', $jquery ); wp_add_inline_script( 'jquery-yith-wcwl-user', $jquery ); } add_action( 'wp_enqueue_scripts', 'yith_wcwl_change_add_to_cart_text', 999 ); }
Check it out and tell us if it works well for you, please.
Best regards.
Hi @juaancmendez,
I tried but it wasn’t changing the ‘Add to Cart’ to ‘Add to Bag’
Hello there,
In our installation the code works correctly. Could you share the link to your site? Maybe the HTML of your page differs from ours.
We will be attentive to your response.
Best regards.
Here is the website
Hello there,
Please replace the previous code with this new one:
if ( ! function_exists( 'yith_wcwl_change_add_to_cart_text' ) ) { function yith_wcwl_change_add_to_cart_text() { $jquery = 'jQuery( function( $ ) { $( ".wishlist_table td.product-add-to-cart a.add_to_cart_button.product_type_simple, .wishlist_table td.product-add-to-cart a.add_to_cart_button.product_type_variation" ).text( "Add to bag" ); });'; wp_add_inline_script( 'jquery-yith-wcwl', $jquery ); wp_add_inline_script( 'jquery-yith-wcwl-user', $jquery ); } add_action( 'wp_enqueue_scripts', 'yith_wcwl_change_add_to_cart_text', 999 ); }
Let us know any news.
Have a nice day!
Perfect! Thank you again
- The topic ‘Change Add to Cart Name’ is closed to new replies.