If you are using WooCommerce for your store, there are many ways you can customize your store using different WooCommerce hooks & filters.
In this post, I will explain how you can hide the ‘Add to Cart’ button on the Shop & product page. But why would you need to hide the ‘Add to Cart’ button, you ask? Isn’t that how people will buy the products?
Well, there can be many reasons you want to hide the button. For example, nowadays, many products are introduced a few days before they are actually allowed to purchase. Many shop owners give detail specifications of the products before they are available to be bought. In such cases, they cannot have the ‘Add to Cart’ button on the page as they don’t want people to buy the product just yet.
Let’s look at how we can hide the button from the product page.
WooCommerce has a filter called ‘woocommerce_is_purchasable‘ in which you can check whether a product is purchasable or not.
For example – let’s hide the ‘Add to Cart’ button from a product whose ID is 335 –
In this example, we check if the current product ID is 335. If yes, then we return false i.e it is not purchasable. If the product ID is not 335, we return true (i.e the product is purchasable). If it is not purchasable, the ‘Add to Cart’ button will not be displayed on the product page.
The product page will look like this –
Show Add to Cart button after a specific date:
Now let’s take this example a bit further. Suppose you want to display the ‘Add to Cart’ button on a specific date (which can be the product’s launch date). This can be achieved automatically without you having to do anything.
Increase WooCommerce Store Sales
"Customer service is great, they go above and beyond to assist and corrected any issues I had with setting everything up in a timely manner. I use the abandoned cart plugin and am very satisfied with the results and carts recovered." - Bran Weintraub
For example – Your product launch is after 10th of October, 2018. You want to hide the ‘Add to cart’ button until then. And display the button on 10th October so that people can buy the product.
Here we check if the current date is less than the release date i.e if the current date is not the release date. If yes, then return false i.e hide the ‘Add to Cart’ button.
Both the above examples will display ‘Read More’ for the product on the shop page with the link to the product page. This is how the product will be displayed on the Shop page –
These examples can be used if you want to give a sneak peak of your product to your customers. You can do this for a single product or multiple products. Try this technique on your store and let us know how it goes.
You can also achieve this with the below mentioned plugins. But if the above code snippet meets your needs, then there is no need to install a plugin.