我需要在我的Woocomerce上四舍五入价格,所以当我的发货插件计算成本时,它会四舍五入为1。不确定这是否有意义,但让我举个例子:
如果购物车的总重量是磅,我需要购物车显示磅( 6.23 lbs
= 7 lbs
)。
我想我需要在functions.php
文件中输入一个函数,但不确定从哪里开始,我试图自己在不同的在线论坛中挖掘它,但似乎找不到任何关于它的线索。
发布于 2017-08-31 17:25:19
有点晚了,但也许仍然有用。您可以尝试使用woocommerce_cart_contents_weight
挂钩:
add_filter('woocommerce_cart_contents_weight', 'round_cart_contents_weight');
function round_cart_contents_weight($weight) {
return ceil($weight);
}
发布于 2020-04-16 23:42:10
您需要先进行舍入,然后返回$weight
。
add_filter('woocommerce_cart_contents_weight', 'round_cart_contents_weight');
function round_cart_contents_weight($weight) {
$weight = ceil($weight);
return $weight;
}
https://stackoverflow.com/questions/40024214
复制相似问题