Change number of decimals in Woocommerce cart totals

前端 未结 3 643
走了就别回头了
走了就别回头了 2021-01-23 04:46

In Woocommerce, I\'ve set the number of decimal to 7 on in Woocommerce general settings, so I can display the product price like this $0.0453321

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-23 05:17

    If you want to change cart total only at cart and checkout page then you need to copy template in your theme

    First copy 2 files from woocommerce plugin template to your theme .

    1) Copy plugins\woocommerce\templates\cart\cart-totals.php to your-theme-folder\woocommerce\cart\cart-totals.php

    2) Copy plugins\woocommerce\templates\checkout\review-order.php to your-theme-folder\woocommerce\checkout\review-order.php

    And in both files find the wc_cart_totals_order_total_html() comment this code and put below code instead.

      $args=array('decimals'=> 2);
      echo  wc_price(WC()->cart->total,$args); 
    

    This code is tested and its working fine.Hope it will help you as well.

提交回复
热议问题