如何将送货方式设置为送货类。像一个例子
Flate rate shipping class - Flate rate method Usps运输类 - Usps方法
或者
我们怎么能挂钩?
答案 0 :(得分:0)
使用woocommerce_package_rates
挂钩。这样就可以了
add_filter('woocommerce_package_rates','manage_method_basedon_shipping_class',10,2);
function manage_method_basedon_shipping_class($methods, $package)
{
// $package have cart items, so loop through that and get your shipping classes available in the cart. like $item->get_shipping_class().
// So you have all the classes now. Now based on this unset shipping methods from $method function. $method have all available shipping methods
// now return $methods;
}
我在上面的代码中写了逻辑,而不是实际的发货ID。这很简单。你可以管理它。