doukang2003 2018-05-08 20:08
浏览 20
已采纳

整理Woocommerce

I need to round up prices on my Woocommerce cart. It rounds up to 1. For example:

If the total price of the cart is $40.85, I need the cart to show $41.00.

I tried with this command but the price discount this 0.15 and I do not know how to do it. I found this in other sites but round up the products in the catalog.

add_filter( 'woocommerce_calculated_total', 'custom_calculated_total', 10, 2 );
function custom_calculated_total( $total, $cart ){
    return round( $total - ($total * 0.15), $cart->dp );
}

Thanks for your help.

  • 写回答

1条回答 默认 最新

  • doufen1890 2018-05-08 21:26
    关注

    I believe this is what you're looking for. This will round your cart total to the next dollar. You can also use WooCommerce settings to round displayed product prices before items are added to the cart.

    //round cart total up to nearest dollar
    add_filter( 'woocommerce_calculated_total', 'custom_calculated_total' );
    function custom_calculated_total( $total ) {
    $total = round( $total, 1 );
    return ceil($total);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效