我想在Woocommerce中添加170g的基础作为基础包装的重量(用于发送物品)。因此,所有产品/物品的重量将增加到170克,并使订单总重量。
我找到了类似的内容:更改每个购物车项目的重量,以更新堆叠溢出中WooCommerce的运费。这正是我需要的,但不是每个项目,而是每个订单一次。
对不起我的英语:)
答案 0 :(得分:0)
如果您使用的是WC_Cart->get_cart_contents_weight()
方法,则可以使用woocommerce_cart_contents_weight
过滤器来改变总重量。
add_filter( 'woocommerce_cart_contents_weight', 'prefix_filter_cart_contents_weight' );
function prefix_filter_cart_contents_weight( $weight ) {
/**
* Adding 170 units to the total cart weight.
*/
return $weight + 170;
}
https://gist.github.com/vanbo/f71ecf4597b79baecd0a71250011149d