2017-05-26 40 views
0

如何将运输方式设置为航运类。类似的例子如何在航运商业中将航运方法设置为航运类?

统一费率航运类 - 统一费率方法 USPS航运类 - USPS方法

或者

怎能由钩也?

+0

你正在使用哪个插件? –

+0

Woocommerce和woocommerce usps插件 –

+0

检查这篇文章https://www.xadapter.com/hide-shipping-methods-shipping-classes-exist-not-exist-cart/ –

回答

0

使用woocommerce_package_rates hook.This将窍门 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。这很容易。你可以管理它。