Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Reuben Mansell
Reuben Mansell
5,134 Points

Woo Commerce Add to Cart Button and URL link

Hey Treehouse people,

I have an issue with WooCommerce (Wordpress) which I am trying to get my head around.

On a simple product in the shop view, I am looking for a way to change the button from "Add to cart" to "Read More". I also need the read more button to click through to the individual product page.

I have found a way to change the button text, but this doesn't change the url so you end up with a "Read More" button which still adds the product to the cart - which i don't want.

Does anyone know of a solution?

I'm running bridge theme along with the WooCommerce Booking system plugin. So some of the products are bookable and some are simple - i'm looking for a way to make the two product types give the same user experience.



2 Answers

Andrew Dushane
Andrew Dushane
9,264 Points

I haven't done it, but you should be able to use the filter hook - woocommerce_add_to_cart_handler - to remove the Add to Cart button and add a link to the full post. http://docs.woothemes.com/document/hooks/

Reuben Mansell
Reuben Mansell
5,134 Points

Hi Andrew,

Thanks for your help.

I managed to get it working using the following code in functions.php:


function add_to_cart_link_revised() {
    echo '<button class="qbutton add-to-cart-button button add_to_cart_button product_type_simple product_type_booking">Read More</button>';

I didn't get as far as working out how to point the button to a different link, but it works as it is as the whole div it sits inside clicks through to the correct place now which is the product details page. If you have any pointers on where to put the url code that would also be useful to know.

Thanks again for your help,