问题
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