Woocommerce使用MYSQL更新库存数量

时间:2018-03-22 09:08:41

标签: mysql woocommerce

我找不到Woocommerce中库存数量的元键。使用MYSQL更新Woocommerce中库存数量的最佳方法是什么?

1 个答案:

答案 0 :(得分:0)

使用 PHP 函数更安全。但是如果你想使用sql更新,你可以试试这个:

检查库存

SELECT * FROM olenka.wp_postmeta where meta_key = '_stock';

检查库存状态:

SELECT post_id AS id, meta_value AS stockstatus FROM wp_postmeta WHERE meta_key = '_stock_status'

设置管理库存为真:

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

设置“有货”标志:

UPDATE wp_postmeta set meta_value = 'instock' WHERE meta_key = '_stock_status' AND meta_value = 'outofstock'

更新库存

UPDATE wp_postmeta SET meta_value = 99 WHERE meta_key = '_stock' AND meta_value IS NULL;

UPDATE wp_postmeta SET meta_value = 99 WHERE meta_key = '_stock' AND meta_value > 0;