【问题标题】:Woocommerce Filter customization (rounding vs floor)Woocommerce 过滤器自定义(四舍五入 vs 下限)
【发布时间】:2016-10-10 07:43:13
【问题描述】:

我在 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 ) ); 

任何帮助将不胜感激。问候!

【问题讨论】:

    标签: wordpress filter woocommerce rounding floor


    【解决方案1】:

    完成!

    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 );
    

    【讨论】:

      猜你喜欢
      • 2021-08-05
      • 2013-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-29
      • 1970-01-01
      • 1970-01-01
      • 2019-02-13
      相关资源
      最近更新 更多