WooCommerce: Show In Stock Products First @ Shop

We’ve already seen how to add a custom “Product Sorting” option to the “Default Sorting” dropdown in the Shop page.

The task I was presented with, however, was to display items based on a custom “meta key”. Now, if you have no idea what a “meta key” is, don’t worry too much. For example, “stock status” is one of these keys, and therefore you can sort products by that.

Anyway, let’s abandon the Japanese for now (hey, unless you speak Japanese!) and get into the coding – as usual, simply copy/paste this little plugin in your functions.php and you’ll get the wanted result ๐Ÿ™‚ Continue reading WooCommerce: Show In Stock Products First @ Shop

WooCommerce: Display Out of Stock Products (Shortcode)

A client of mine wanted to show out of stock products on a separate page – so I coded a simple shortcode for you all!

You can use this same shortcode for different goals. For example, you might want to display what products you’ve sold so far to enhance customer trust (which is the same as displaying those products that are not in stock). Or maybe, you might want to have a specific page where customers can go to see what’s coming back in stock (if you don’t sell unique pieces and restock your products).

Either way, let’s see how to (1) create a shortcode and (2) how to use a WordPress query to return just those products that have 0 stock! Continue reading WooCommerce: Display Out of Stock Products (Shortcode)