How do I fill in product costs without clicking through 500 products?
The core admin has one cost field and no bulk editor for it. The routes that do scale, and the order of work that makes a profit report useful after one evening.
The short answer
The WooCommerce admin gives you one cost field per product, in the General tab, and no bulk editor for it. For a large catalogue the routes that scale are the REST API and WP-CLI.
The shortcut that matters more than either: you do not need every product. Enter the cost for the products that actually sell and the report becomes useful straight away — in most shops the first fifty products carry the large majority of the revenue.
What WooCommerce actually does
The core exposes the cost in three places:
- the product editor — General tab, one product at a time;
- the REST API —
productsandvariationscarry acost_of_goods_soldobject with the defined value and the total; - the object API —
WC_Product::set_cogs_value()andget_cogs_value(), which is what any script or importer ends up calling anyway.
There is also a lookup column, wc_product_meta_lookup.cogs_total_value, which is NULL for a
product with no cost entered. That is how a list of products with no cost gets built without
crawling the meta table row by row.
What to do about it
Work top-down, not alphabetically. Sort your products by revenue, take the first page, and enter those costs first. Coverage climbs fastest that way, and coverage is what makes the rest of the report worth reading.
For many products at once, one call per product from WP-CLI:
wp eval '$p = wc_get_product( 123 ); $p->set_cogs_value( 41.50 ); $p->save();'
To drive it from a spreadsheet, loop over a CSV of id,cost in a small script and call the same
two methods. This writes to your shop, so try it on a copy first and keep a database backup.
It is your script and your data; none of it goes through Merchgain.
A cost entered today applies to future orders only. Orders already in the database keep whatever they recorded at the time, which for older orders means nothing at all.
How Merchgain reports it
Merchgain shows how many products have no cost, links each one straight to its product editor, and prints how much revenue that gap represents. Those links are the working list: open, type the cost, save — and the report drops its cache immediately instead of waiting out the hour.
Merchgain never writes a cost, and it has no bulk cost editor. A plugin that fills in cost values is no longer a plugin that only reads.
Related answers
Disagrees with what you see in your shop? Write to us — every message is read. contact@merchgain.com