在選擇使用smartbundle的時候,如果忘了把sku清空,在匯入資料時會變成多匯商品;如果有匯入進銷存軟體的需求,可以把sku的值改成折讓的貨號
add_action('woocommerce_admin_process_product_object', 'clear_sku_if_smart_bundle');
function clear_sku_if_smart_bundle($product) {
// 獲取商品類型
$product_type = $product->get_type();
// 如果商品類型是 Smart bundle (woosb)
if ($product_type === 'woosb') {
// 清空貨號(SKU)
$product->set_sku('');
}
}