Skip to content

Instantly share code, notes, and snippets.

@lukecav
Created July 5, 2023 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukecav/ef32fdbd50c0f2daf4de8db8a2491e37 to your computer and use it in GitHub Desktop.
Save lukecav/ef32fdbd50c0f2daf4de8db8a2491e37 to your computer and use it in GitHub Desktop.
Set all product inventory stock to zero in WooCommerce
UPDATE wp_postmeta pm
INNER JOIN wp_wc_product_meta_lookup pml
ON pm.post_id = pml.product_id
SET pm.meta_value = '0', pml.stock_quantity = '0'
WHERE pm.meta_key = '_stock';
UPDATE wp_postmeta pm
INNER JOIN wp_wc_product_meta_lookup pml
ON pm.post_id = pml.product_id
SET pm.meta_value = 'outofstock', pml.stock_status = 'outofstock'
WHERE pm.meta_key = '_stock_status';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment