Module 3 · 3.4
Stock and products in bulk
Module 3: Products · Reading time: 10 minutes
Learning objective: After this lesson you can set up stock in WooCommerce deliberately (management, holding, notifications, backorders, out of stock products) and safely export and import products in bulk with a CSV file.
Key concepts: stock management, stock per product or per variation, hold stock, low stock threshold, out of stock threshold, stock notifications, backorders, hiding out of stock products, stock display format, CSV export, CSV import, updating existing products, character set (UTF-8), delimiter, links with a till system or wholesaler
Why stock is more than a number
A stock figure looks simple: you have twelve teapots, twelve go out the door, then you have none left. In a web shop, things happen at the same time. Two customers put the last teapot in their basket. A customer starts paying and changes their mind halfway through. You also sell the same teapot in your physical shop or at a market. Incorrectly configured stock leads to the worst thing that can happen to a shop: a paid order you cannot deliver. That costs you a refund, an angry customer and sometimes a bad review.
WooCommerce has a set of settings for this. You find them under WooCommerce > Settings > Products > Inventory, and per product in the Inventory tab.
The settings one by one
Manage stock (Enable stock management) is on by default. Per product, you then choose whether WooCommerce keeps track of quantities. Without quantities, you only set the status: in stock, out of stock or on backorder. That suits products you make to order or can always deliver. For a variable product, you choose whether stock applies per variation or to the whole product (lesson 3.2).
Hold stock (minutes), 60 by default. When a customer starts checking out, WooCommerce creates an order with the status Pending payment and sets the stock aside. If payment has not arrived after this number of minutes, WooCommerce cancels the pending order and the stock is released. Too short, and a customer who needs to log in to their bank sees their order cancelled. Too long, and a teapot stays reserved for half a day for someone who left long ago. An hour is reasonable for most shops. Note: the cancelling is a scheduled task. If your scheduled tasks do not run properly, unpaid orders get stuck (lesson 7.3).
Notifications: an email for low stock, out of stock and backorders, sent to the administrator address by default. Enter the address of whoever does the purchasing.
Low stock threshold, 2 by default, and Out of stock threshold, 0 by default. Do you also sell in a physical shop and update the web shop only once a day? Then set the out of stock threshold to 1 or 2. That way the web shop will not sell the last item, which may already have been sold in the shop.
Out of stock visibility (Hide out of stock items from the catalog), off by default. Hiding keeps your shop pages tidy. But an out of stock product that comes back temporarily loses its place in the category. The product page itself stays reachable. Lesson 7.1 covers what that means for being found.
Stock display format: always show the quantity ("12 in stock"), only when low ("Only 2 left in stock"), or never. "Only 2 left in stock" helps customers decide, but only show it when it is true; artificial scarcity is misleading.
Allow backorders? per product: do not allow, allow but notify the customer, or allow. Allowing backorders means customers can buy while you have nothing in stock. That can work for a product you are sure to receive within a week. In that case, do tell the customer (the middle option) and state a realistic delivery time: the delivery time is part of the information you give before the purchase (lesson 5.1).
Links and a single source of truth
If you sell in several places (web shop, shop with a till, a marketplace) or a wholesaler delivers directly to your customers, you quickly end up with two or three stock lists. Choose a single source of truth: the system that determines the real stock. Usually that is the till or the inventory system, and WooCommerce receives the quantities through a link. Such a link uses the SKU as its key. A product without a SKU, or a SKU spelled differently in the till, will not be updated. That is why the SKU was so important in lesson 3.1.
Links usually use the WooCommerce REST API with an API key. Give such a key only the permissions it needs (lesson 2.4).
Products in bulk: exporting and importing
For ten products, you work in the admin. For a hundred price changes, a new season or a move from another shop system, use the built-in CSV export and import: the Export and Import buttons above the product list under Products > All Products.
A CSV file is a text file with one line per product and columns separated by commas. You open it in a spreadsheet program. That is often where things go wrong:
- Character set. WooCommerce uses UTF-8. If your spreadsheet program opens the file in a different character set, "é" turns into something like "é". Explicitly choose UTF-8 when opening and saving.
- Delimiter and decimal separator. With Dutch settings, a spreadsheet program often uses the semicolon as the delimiter and the comma as the decimal separator. WooCommerce expects a point in prices (24.00). A price of "24,00" may be read as something else. Check a few lines in a text editor before you import.
- Empty columns. When updating, an empty cell can mean that a value gets cleared. It is better to leave columns you do not want to touch out of the file altogether.
- Variations. Each variation is a separate line, with a reference to the parent product.
When importing, choose Update existing products. WooCommerce then looks up an existing product by ID or SKU. With that option, products that do not exist are skipped. Without it, the import creates new products, and a SKU that already exists gives an error.
Working safely: start small, start somewhere else
An import can change hundreds of products in one click. So:
- Make a backup (WordPress course, lesson 8.1), or work in your test shop first (lesson 2.1).
- Export first, so you have a file with the current state.
- Test with a file containing one line. Check the product in the admin and on the site.
- Only then apply the whole file.
- Large files can hit the PHP upload limit or time limit. Split them into parts, or ask your host about the PHP settings (knowledge base 200).
Summary
- Managing stock prevents paid orders you cannot deliver.
- Hold stock (60 minutes by default) reserves items during payment; the cancelling afterwards is a scheduled task.
- Set thresholds, notifications, visibility and backorders deliberately, with an honest delivery time.
- Choose a single source of truth and use the SKU as the key for links.
- CSV import: UTF-8, a point as decimal separator, export first, test with one line, update by ID or SKU.
Quiz
Exercise
Exercise D3.4: Exporting and importing. Do this in your test shop or after a fresh backup.
Steps:
- Export all your products to a CSV file with the Export button above the product list (Products > All Products).
- Open the file in a spreadsheet program and choose UTF-8. Note which delimiter and which decimal separator you see.
- Create a new file with only the columns ID (or SKU) and Stock, with one product. Change the stock.
- Import that file with the Import button above the product list, with Update existing products turned on.
- Check the product in the admin and in a private window on the site.
- Go through your stock settings under WooCommerce > Settings > Products > Inventory.
Checklist (required): backup or test shop; export made; file opened with the correct character set; one line changed; only that line imported with "Update existing products"; result checked.
Answer:
- Which column did WooCommerce use to find the product: ID or SKU?
- What went wrong or almost went wrong (characters, decimal separator, empty columns)?
- Which stock settings do you use (hold stock, thresholds, notifications, backorders) and why?
A good answer names ID or SKU as the key, a concrete pitfall you ran into or avoided, and for each setting a reason that suits your shop.
Exercise D3.4: Exporting and importing
You do this exercise yourself; no one checks it. Tick off what you've done and mark the exercise as done.
ID or SKU as the key; one concrete pitfall (comma as decimal separator, semicolon as delimiter, é becomes é); a choice for backorders with a reason.
Your ticks and notes only stay in this browser; we don't send them anywhere. If you're signed in, we only save in My courses that you've done the exercise.
Further reading
- Product CSV importer and exporter (woocommerce.com): https://woocommerce.com/document/product-csv-importer-exporter/
- Free WordPress course 8.1: Backups: what, where and how often
- Upload fails: increase upload_max_filesize and max_execution_time
- DirectAdmin guide 18.5: Upload too large (error 413) or timeout
- Importing and exporting products in bulk using CSV
The steps in the knowledge base and the manual apply to the WebOké panels; with other providers it works in a similar way.
