SQL query to change backorder status of all products in WooCommerce

烂漫一生 提交于 2020-01-16 18:10:36

问题


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?


回答1:


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';


来源:https://stackoverflow.com/questions/55160670/sql-query-to-change-backorder-status-of-all-products-in-woocommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!