There are lots of fun things you can do to WooCommerce [Buy Now] and [Add to Cart] buttons.
Here I’ll show you a few ways you can customize WooCommerce buttons which appear in The Loop (Shop Frontpage, Shop Category pages, etc…). You can add the code snippets below to a Custom Plugin.
First, let’s see how buttons look like be default. Here is a screenshot of 3 products on a category page. All 3 of these products are External (or Affiliate) products so they display a greyed out [Buy Now] button.
Default Button Display in WooCommerce Loop
Add Highlighting to Buttons for Products On Sale
This one will format the WooCommerce buttons by highlighting the buttons for products which are on sale.
Here’s what that would look like:
The custom code for that looks like this:
Remove Buy/Add Buttons
In some cases you may want to remove the buttons altogether. This might be useful for the next few code snippets.
Here’s how to remove the Buy/Add buttons from your WooCommerce Loops.
Add [More Details] Button Linking to Single Product Page
Now that the Buy/Add button is gone, we can add some other buttons to The Loop.
Here we will add a [More Details] button which links to the single product page.
While it’s not that exciting, we will build on this in the following examples. But if you like this, here’s the code:
Link Directly to External/Affiliate Site from [More Details] Button
The one is strictly for External/Affiliate products. This adds a new [More Details] button which links directly to the external/affiliate website instead of your single product page.
This looks very similar to the default functionality of WooCommerce.
And here’s the custom code:
Add Price to Button
Here we will add the product’s price (regular or sale price) to the button. This helps prices stand out a bit more.
Here’s the custom code for that:
Add Merchant’s Name to Button
Here’s another one that works well for External/Affiliate products. We can also add the merchant’s name to the button.
And here’s the code:
Those are all for the WooCommerce Loop but if you want to make similar customizations on the Single Product Page, you would want to use the