我找不到Woocommerce中库存数量的元键。使用MYSQL更新Woocommerce中库存数量的最佳方法是什么?
答案 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;