[英]Make all products in woocommerce as "Out Of Stock" ( Remove all products quantity )
I have a woocommerce store and I want to make all the products ( including variable products ) quantity to 0. So, all the products will be out of stock.我有一个woocommerce商店,我想让所有产品(包括可变产品)数量为0。因此,所有产品都将缺货。 I am not getting any plugin to do it.我没有得到任何插件来做到这一点。 I have atleast 2100 products in the inventory.我的库存中至少有 2100 种产品。 So, it is not feasible to do it manually.因此,手动执行此操作是不可行的。 Is there any other way I can do this automatically ?有没有其他方法可以自动执行此操作?
Thanks.谢谢。
安装 PhpMyAdmin 插件并直接编辑相关数据库表中的数量。
You can paste this code in your functions.php in your child theme.您可以将此代码粘贴到您的子主题中的functions.php 中。
$products = $wpdb->get_results("SELECT * FROM `".$wpdb->postmeta."`");
foreach($products as $product){
if(get_post_type($product->post_id) == "product"){
$product_id = $product->post_id;
wc_update_product_stock($product_id, 0, 'set');
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.