Woocommerce 过滤器定制(四舍五入与地板)
Woocommerce Filter customization (rounding vs floor)
我在 Woocommerce 源代码中有这个过滤器:
$this->total = max( 0, apply_filters( 'woocommerce_calculated_total', round( $this->cart_contents_total + $this->tax_total + $this->shipping_tax_total + $this->shipping_total + $this->fee_total, $this->dp ), $this ) );
我想对我的过滤器应用此更改,但我不明白如何操作。
$this->total = max( 0, apply_filters( 'woocommerce_calculated_total', floor(( $this->cart_contents_total + $this->tax_total + $this->shipping_tax_total + $this->shipping_total + $this->fee_total) * 100)/100, $this ) );
如有任何帮助,我们将不胜感激。问候!
完成!
function custom_round_function( $total, $cart ) {
$total = floor(($cart->cart_contents_total + $cart->tax_total + $cart->shipping_tax_total + $cart->shipping_total + $cart->fee_total) * 100)/100;
return $total;
}
add_filter( 'woocommerce_calculated_total', 'custom_round_function', 10, 2 );
我在 Woocommerce 源代码中有这个过滤器:
$this->total = max( 0, apply_filters( 'woocommerce_calculated_total', round( $this->cart_contents_total + $this->tax_total + $this->shipping_tax_total + $this->shipping_total + $this->fee_total, $this->dp ), $this ) );
我想对我的过滤器应用此更改,但我不明白如何操作。
$this->total = max( 0, apply_filters( 'woocommerce_calculated_total', floor(( $this->cart_contents_total + $this->tax_total + $this->shipping_tax_total + $this->shipping_total + $this->fee_total) * 100)/100, $this ) );
如有任何帮助,我们将不胜感激。问候!
完成!
function custom_round_function( $total, $cart ) {
$total = floor(($cart->cart_contents_total + $cart->tax_total + $cart->shipping_tax_total + $cart->shipping_total + $cart->fee_total) * 100)/100;
return $total;
}
add_filter( 'woocommerce_calculated_total', 'custom_round_function', 10, 2 );