By default, WooCommerce external products do not have and do not display any stock, as they are simple redirects to an external URL. This may be unfortunate, because before clicking on an external URL and send people away from your website, you may want to make sure the current item is in stock (so that you have more chances to convert the sale and earn a referral commission, if that’s your business model).
So, how do we “manage stock” for an external product, and display the stock status on the single product page, just before the “Buy Product” button?
Continue reading WooCommerce: Display Stock Status For External Products
The WooCommerce plugin allows you to manage stock for each product, but you only have a single stock quantity field!
What if you have two warehouses and, as a store admin, need to manage the inventory for each location? Besides, what if an item is out of stock at location 1, but it’s in stock at location 2, and therefore the customer needs to be able to purchase it?
This amazing workaround will add a second input number in the product settings, redefine stock quantity and status on the frontend by summing up stock 1 + stock 2, and finally decrease stock 1 until it goes to 0, after which it will decrease stock 2.
This default behavior can be changed of course e.g. it’s possible to define from where the stock is reduced (by distance?) via additional code. Also, additional code can be written to make it compatible with variable products or custom product types, as well as make it work with refunds. Either way, enjoy!
Continue reading WooCommerce: Additional Stock Inventory Location
It’s great that WooCommerce products clearly display their stock status and quantity on the single product page (and on the shop page, with this simple customization).
However, WooCommerce store owners often need to display the stock quantity in other sections of the website, such as the homepage, a blog post, a custom pricing table, and keep the quantity dynamic so that the text changes when there is a stock change.
We can therefore build a simple shortcode, that can automatically update the output, so that you never need to worry about changing that piece of content ever again. Enjoy!
Continue reading WooCommerce: Stock Quantity in a Shortcode
When an order that has previously reduced stock is “cancelled” or goes to “pending payment” because the payment failed or the store admin decided to change the order status, the wc_maybe_increase_stock_levels() function triggers and restores the order items’ stock quantity.
As usual, some WooCommerce entrepreneurs asked for a way to disable this automatic restocking given their custom setup. It often goes like that – you can’t really please everyone.
This is unless you’re a smart developer and can account for both options, thanks to a WordPress “filter“. Here’s a PHP one-liner that can immediately disable this default behavior, so that you can avoid the automatic restocking (and maybe doing it manually based on your business rules). Enjoy!
Continue reading WooCommerce: Disable Restocking @ Order Cancelled
We’ve already coded a solution to display WooCommerce out of stock products only via a custom shortcode – today we’ll do the opposite: how can we display in stock products only via a handy shortcode?
Once again, the solution “gets” the list of products IDs that are in stock, and then passes the result to the official [products] WooCommerce shortcode, so that we don’t reinvent the wheel.
You can then use the [in_stock_products] shortcode anywhere you wish – on a blog post, in a custom page, in a widget, and so on. You can even customize the output with the official WooCommerce [products] shortcode parameters such as columns, orderby, limit, etc. Enjoy!
Continue reading WooCommerce: In Stock Products Shortcode
When questions such as “How do you save the product stock inventory history?” pop up in our private Bloomer Armada slack channel for WooCommerce developers, I can’t really do without thinking of coding it myself!
This neat customization saves the stock quantity of a simple product or a variable product variation before there is a stock change, due to a manual stock quantity edit or a customer order.
Please bear in mind that if you have hundreds of stock movements per product this may slow down your backend and/or database, so the snippet may need some sort of optimization or limitation (“last 10 movements”).
So, let’s see how it works. Enjoy!
Continue reading WooCommerce: View Stock History @ Product Admin
Sometimes, the nature of ecommerce businesses requires some extra features. Thankfully, WooCommerce allows to customize pretty much everything based on whatever condition.
Today, we’ll see how to hide prices for out of stock items, on the shop, categories, archives, loops and single product page.
Think of an art gallery which sells unique art pieces, and doesn’t want to let users know for what price sold an item. Or maybe an online business that often runs discounts – why reveal at which price sold an item that is now out of stock? Of course, there are way more case scenarios – I’d be curious if you shared yours in the comment area.
But for now, copy and paste the snippet and that’s it, you’re good to go. Enjoy!
Continue reading WooCommerce: Hide Price If Product Out of Stock @ Frontend
This is a neat customization, directly requested by a WooWeekly subscriber who needed to literally show the remaining stock quantity for each ordered item to store managers, in order to have an immediate idea of low/zero stock quantities after each order.
If that’s not clear, simply take a look at the screenshot. In my dev site, I ordered a product that originally had stock quantity = 1. In the “New Order” email (thanks to the snippet below), beside the order item quantity of 1, there is also a “(0 remaining)” notice that clearly displays the item’s current stock level.
Cool, ha? So, let’s see how that’s coded. Enjoy!
Continue reading WooCommerce: Remaining Stock @ Order Emails
Each WooCommerce business is different, which means customization is required to adapt the store to unique specifications.
A clear example is the stock quantity. Not all stores can display the standard notice “11 in stock”. The display could change to “11 Kg in stock” if stock is based on weight. Or maybe “11 boxes in stock” or “11 pairs in stock” in case the package description is useful UX-wise. Also, “11 m3 in stock” if the business sells volumes.
Either way, this is a nice trick to display a “stock quantity suffix” in your WooCommerce Single Product Page. Enjoy!
Continue reading WooCommerce: Stock Quantity Suffix e.g. “sq. in.”, “Kg”, “boxes”, etc.
There is an unfortunate (IMO) add to cart button naming on the WooCommerce shop page / category pages / product loops. When an item is out of stock, the “Add to cart” (or “Select options” for a variable product type) button label will turn into “Read more”.
To be honest, that doesn’t really say much to the end customer. It’s quite confusing and doesn’t make much sense.
Today, we’ll see how to change that “Read more” label into something more comprehensible: “Out of stock”. A super easy trick. Enjoy!
Continue reading WooCommerce: Rename “Read more” To “Out of stock” @ Shop
There’s no better feeling than “selling out” and still having more customers who want to buy your products. But while this image looks exciting, it comes with a considerable downside.
Sold-out products put you at risk of losing customers – simply because they wouldn’t know when a product is back in stock to purchase it. They can also frustrate your customers and make them buy from your competitors instead, leading to business and customer loss.
But what if there was a way to avoid this?
By enabling waitlists for your online store, you can keep customers updated about their favorite product’s availability and immediately notify them when it’s back in stock.
This will not only help you keep customers engaged but also prevent you from losing valuable sales. You don’t have to take our word for it – research suggests notifying customers when products come back in stock turns 10-15% of requests into actual purchases.
Creating and managing waiting lists online can be pretty taxing with all the back-and-forth. Good thing you have WooCommerce waitlist plugins to make the job easy for you. These plugins help you manage your stock, add customers to waitlists, and automatically send alerts about their desired products.
This article will take you through six of the best WooCommerce waitlist plugins that can help you recover missed sales. But first, let’s understand how these plugins work and can help your bottom line.
Continue reading WooCommerce: Waiting List for Out-Of-Stock Products
WooCommerce stores with large inventory often decide to hide out of stock products from the website. As you all know, there is a WooCommerce setting for that, right under Settings > Products > Inventory called “Out of stock visibility“. With the tick of a checkbox you can toggle the visibility of products that ran out of stock and immediately return a clean shop page with no unpurchasable items.
The story is, it could be you may want to still show out of stock items on a specific page via a custom shortcode, or limit the out of stock visibility setting only to certain categories.
Well, today we will learn a cool WordPress hook called “pre_option_option“, that basically allows us to override whatever settings we have in the WordPress admin, and assign our own value on a specific page or condition. Enjoy!
Continue reading WooCommerce: “Hide Out of Stock Items” Exception
There are times when the WooCommerce product settings alone are not enough. You can already tick the “Sold individually” checkbox in the “Inventory” product data tab in the single product edit page to force quantity 1 for whatever product: “Enable this to only allow one of this item to be bought in a single order“.
Problem is, you may need to set this “programmatically” (via code), based on certain conditions. One reason is that you may not want to edit hundreds of products one by one (or in bulk) – another is that you may want to “override” whatever settings based on certain conditions (for example, you set “Sold Individually”, but if the Cart total is greater than 100 you want to allow quantities greater than 1).
As you can see, in this post we will cover, once again, the magic of “conditional logic“. Enjoy!
Continue reading WooCommerce: Conditionally Force Product Quantity 1 @ Cart
We’ve already seen how to display stock quantity and status on the Shop Page – today we’ll do something similar, but this time we’ll work on the Cart product table, so that we can visually display stock status and quantity to WooCommerce customers who are about to checkout.
Please note – in order for the snippet to work you must have “stock management” enabled, and also each single product in the cart must have “managing stock” checked and, if on backorder, “allow but notify customer” must be selected, otherwise you will see nothing. Enjoy!
Continue reading WooCommerce: Show Product Stock @ Cart Page
We’ve already seen how to add a custom “Product Sorting” option to the “Default Sorting” dropdown in the WooCommerce 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 key as opposed to product name, date, price, etc.
So, let’s see how to show all out of stock products as last in the shop, category and loop pages. As usual, simply copy/paste this little plugin in your functions.php and you’ll get the wanted result 🙂
Continue reading WooCommerce: Display “In Stock” Products First @ Shop
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 shortcode for different goals. For example, you might want to display what products you’ve sold to enhance customer trust / social proof.
So let’s see (1) how to create a shortcode and (2) how to take advantage of the existing [products] WooCommerce shortcode and its “ids” parameter to pass just those product IDs that are out of stock!
Continue reading WooCommerce: Display Out of Stock Products (Shortcode)
Thanks to the various requests I get from Business Bloomer fans, this week I’m going to show you a simple PHP snippet to echo the variations’ name and stock quantity on the shop, categories and loop pages.
Of course, if “Manage stock” is not enabled at variation level, the quantity will be null, and therefore the returned string will just say “In stock” or “Out of stock”.
Continue reading WooCommerce: Display Variations’ Stock @ Shop Page
In this tutorial, my goal is to show the “stock availability” under each product in the shop, category and archive pages.
This follows exactly the same settings as the stock display of the single product page. Go to /wp-admin/admin.php?page=wc-settings&tab=products§ion=inventory to manage “Stock display format”. Enjoy!
Continue reading WooCommerce: Display Stock Availability @ Shop Page
Here’s another simple snippet that can easily help user experience and make sure a “sold out” badge shows on each out of stock product in the category & shop pages.
Not all themes allow this so you can use the snippet below to make it happen!
Continue reading WooCommerce: Show “Sold Out” @ Shop Page
I’ve seen many snippets that change the “In Stock” text on the single product page, but not the FULL string. In this particular case, not only I needed to change the text, but also edit the order of display: from “2 in stock” to “Quantity: 2“.
Continue reading WooCommerce: Edit “# in stock” @ Single Product Page