Template Files for Product Category and Product Tag Pages

What PHP file does WooCommerce Shop Page use?

How to Hide Out of Stock Products

By default, when a product is out of stock it is still going to be displayed on your shop and product archive pages and there is going to be “Read more” button instead of “Add to cart”, like this:

Out of stock items are displayed by default

But if you are reading this, I suppose you do not want them to be displayed, right? ;)

Change Related Products Text

Change or Remove Sale Badge

WooCommerce sale badge is displayed automatically for products that are currently on sale. But what if you don’t like its default design or maybe you would like to change its text or even to completely remove it. We will dive into it in this tutorial.

Get Number of

Let’s skip the introduction part and get straight to the solution. There are actually two ways depending on what you are going to achieve:

  • WC()->cart->get_cart_contents_count() – it allows to get a number of cart items including their quantity counts. For example, if you have 10 snowboards and 1 avocado toast in the cart, this method will return 11! You can see it yourself if you open this method in WooCommerce source code. It just gets the whole cart array from WC()->cart->get_cart() and then for each item it gets its quantity parameter.
  • count( WC()->cart->get_cart() ) – this implementation actually returns the number of unique products in the cart, one per product.

How to Get Default Page URLs

If you go to Pages > All Pages after WooCommerce installation, you will notice that a couple more pages appeared there. These are kind of system pages in WooCommerce and required to provide your shop visitors proper eCommerce user experience.

The WooCommerce default pages – Cart, Checkout, Shop, My Account

Sometimes, and I might say – very often, when coding something for WooCommerce we need to get these pages URLs programmatically. We can’t use something like site_url( 'cart' ), because website administrators allowed to change the system pages URLs, for example to use instead of and so on.

Luckily there are a couple functions in WooCommerce that allow to get these page URLs dynamically.