Thursday, February 17, 2022

[FIXED] SQL query to change backorder status of all products in WooCommerce

Issue

In WooCommerce you can change the status of a product to allow backorders, the default setting is 'not allowed'. I have thousands of products on my shop and I rather not change it manually for all of them. Is there an SQL query that could do this for me directly in the database?


Solution

Try running this query in mySql

 UPDATE wp_postmeta SET  meta_value = 'yes' WHERE meta_key = '_backorders';

This is not enough to achieve your purpose. Need to enable Manage stock as well.

Try running this query also if WooCommerce allow backorders global settings is not enabled.

UPDATE wp_postmeta SET  meta_value = 'yes' WHERE meta_key = '_manage_stock';

Need to update stock quantity as well

UPDATE wp_postmeta SET  meta_value = 1000 WHERE meta_key = '_stock';

For stock status

UPDATE wp_postmeta SET  meta_value = 'instock' WHERE meta_key = '_stock_status';


Answered By - mujuonly

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.