![](/img/trans.png)
[英]Set all variations out of stock if one variation is out of stock in WooCommerce
[英]Set a variation out of stock in all WooCommerce products
我們有帶有 WooCommerce 的杯子打印系統,我們顯示可用的可打印 colors 作為變體。 我需要在所有產品中設置某個變體缺貨,即,如果我們沒有紅色可用,那么我想在所有產品中設置紅色變體缺貨。
除了手動設置所有產品中的某些變化之外,我沒有找到任何簡單的解決方案。
任何幫助表示贊賞。
$out_of_stock_staus = '缺貨';
// 更新庫存數量 update_post_meta($product_id, '_stock', 0); update_post_meta($product_id, '_stock_status', wc_clean($out_of_stock_staus)); wp_set_post_terms($product_id, 'outofstock', 'product_visibility', true );
我認為您應該管理這個元值來處理 woocommerce 產品的庫存
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.