0
votes

Anyone here knows how to customize the WooCommerce recent product shortcode?

I am trying to view recent products on my homepage without add to cart button yet so they have to click it and see more details on product single page.

By default the shortcode shows thumbnail,Product name, Price and Add to cart button. I want to remove the button.

2

2 Answers

0
votes

There's probably a better solution but i did it this way (i presume you know how to use some FTP program).

  • In your theme folder, create a "woocommerce" folder, and then inside of it, create "loop" folder
  • Then in "loop" folder copy "add_to_cart.php" file from "woocommerce/templates/loop"
  • Open "add_to_cart.php" that you copied and go to line 55 that starts with

echo apply_filters( 'woocommerce_loop_add_to_cart_link', sprintf( <....

  • delete the entire line (don't delete anything after that line)

That way you can remove the "Add to cart" button or you can add instead of it (like i did) something like:

echo '<a href="'.get_permalink( $product->id ).'" rel="nofollow" class=" button">Read more</a>';

which is just a link to the product.

Like i said, there's probably a better way to do it with "functions.php" but i did this way.

0
votes
body.home .add_to_cart_button {
    display: none;
}