只显示一个运费基于车量
在WordPress
我试图找到一种方法,使用2个运费使用Woocommerce:
如果客户订单小于n金额,然后航运是标准的X量
如果客户订单数量超过n,那么发货量减少到x金额
如果订单符合降低运输的条件,我还需要隐藏标准。只显示一个运费基于车量
目前woocommerce同时显示的运输费用,如果订单符合降低运输
任何想法如何,我可以解决这个吗?
感谢
这里是woocommerce_package_rates
动作钩子钩住一个自定义函数,将根据车量限制只显示一个出货率:
add_filter('woocommerce_package_rates', 'hide_sshipping_rate_based_on_cart_amount', 100);
function hide_sshipping_rate_based_on_cart_amount($rates) {
// HERE define the limit amount to switch of shipping rate (integer)
$amout_limit = 600;
// Cart total amount (integer)
$cart_total = WC()->cart->cart_contents_total;
// Set below your 2 Rate ID slugs
if($cart_total >= $amout_limit)
unset($rates['flat_rate:12']); // Removes the LOWER Rate
else
unset($rates['flat_rate:8']); // Removes the HIGHER Rate
return $rates;
}
代码放在的function.php文件你活跃的孩子主题(或主题),或任何插件文件。
嗨LoicSorry我做过,但它没有奏效。我最终找到了一个允许2个运费的插件,试图找到一种方法,现在我们可以将国家分为两部分,但使用相同的国家代码。示例英格兰(GB)苏格兰(GB) – Patdundee
您正在使用哪种woocommerce版本?这真的很有用。你只需要设置2个正确的slu for以获得更低和更高的费率...如果需要,您可以通过Skype聊天与我联系(我的ID是'marsloic')... – LoicTheAztec
您是否尝试过我的答案的代码...只是想知道一些反馈。谢谢 – LoicTheAztec