Tagged: custom button, function.php, woocommerce
-
AuthorPosts
-
November 28, 2017 at 11:44 am #882592
using a code snippet in the function.php file i added custom button to woocommerce product pages
it looks like this// add "back to shop" button to single product pages function add_custom_single_button(){ ?> <script> jQuery(window).load(function(){ var r= jQuery('<a class="second-button" href="https://www.mysite.com/shop/">Return to the shop</a>'); jQuery("button.single_add_to_cart_button").after(r); }); </script> <?php } add_action('wp_footer', 'add_custom_single_button');and it worked perfectly
problem is now i have two different languages in the website (English and Hebrew)
and i’m not sure how to deal with this button
I don’t wont to remove it but it always directs to the original Hebrew shop, even when it appears in the pages of the English shop
..is there a way to modify the function so each languages will have it’s own button text and URL?
(obviously i installed WPML and it’s doing it’s thing but this button text and URL are out of the plugin translation reach)November 30, 2017 at 3:08 pm #883461Shalom Doron,
Please try changing the code to following
// add "back to shop" button to single product pages function add_custom_single_button(){ ?> <script> jQuery(window).load(function(){ var r= jQuery('<a class="second-button" href="https://www.mysite.com/shop/">Return to the shop</a>'); var h= jQuery('<a class="second-button" href="https://www.mysite.com/shop/">Return to the shop in Hebrew</a>'); jQuery("html[lang='en-US'] button.single_add_to_cart_button").after(r); jQuery("html[lang='he-IL'] button.single_add_to_cart_button").after(h); }); </script> <?php } add_action('wp_footer', 'add_custom_single_button');If that does not work, please create a temporary admin login and post it here privately :)
Best regards,
Yigit-
This reply was modified 7 years, 11 months ago by
Yigit.
December 5, 2017 at 11:18 am #884970Hi!
sorry it took me so long to respond (for some reason i didn’t get any email notification)
anyway – it works! like a charm!
thank you so much!December 5, 2017 at 12:49 pm #885021Hi,
Glad to hear that. Thanks for using Enfold :)
Best regards,
Nikko -
This reply was modified 7 years, 11 months ago by
-
AuthorPosts
- The topic ‘change a custom woocommerce button to work with two different languages’ is closed to new replies.
