Don’t Worry, You’re In The Right Place
A lot of these posts were originally on SureFireWebServices.com. So if you found them through search engines or clicking around, this is their new home :). Enjoy!
0

How to change the Add To Cart Link and Text on WooCommerce Archive Page

Well this was a pain to find.  In fact, I didn’t even find it, I ended up hacking a bunch of code together in order to figure it out.  But the good new, I did figure it out, and now I want to share it with you!  So anyone who’s been trying to change the text to the add to cart link for simple products on WooCommerce, I got you.  If you’re trying to change the LINK to the add to cart link so that it goes to the product page, I got you again! 

Let’s start with the resource.  After scouring the internet and twitter to try and find an answer, I came across this cool little website. It had a couple of snippets that seemed legit, but the only problem is that they didn’t work on the latest release of WooCommerce.

Fast forward, I also found this cool snippet of code (can’t remember where) that allows you to change the text of the WooCommerce buttons by the type of product!

[gist id=”c1b3db44d0cd761b14f1″ file=”woo-text-change.php”]

Now pay attention to the function.  You can keep the filter there if ALL you want to do is change the text that displays. But if you want the link, all you need is the function.

The second step is to now change the link.  I did this by copying and pasting the original HTML for the a tag. This way all the classes, etc., are kept in tact. Then I added the appropriate php variables.

[gist id=”c1b3db44d0cd761b14f1″ file=”woo-change-addtocart-link.php”]

And that’s it! Now you can control the link AND the text! In fact, you have full control over the link so you can make it a button, a form, whatever you want, it’s there! Keep the text-change function, and you’ll be able to change the text for any type of product you have.

Tada!

Hope you enjoy!

Advertisement
About the Author
What's UP! This is my site, I write 99% of the articles on here. I'm also the owner of SureFireWebServices.com. I help out a lot of developers and designers getting into the web game. Helping is fun for me, so feel free to ask me any questions! I've made courses and have a membership as well to help get you on your feet!

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top