• darius00klokj

    (@darius00klokj)


    The _order_shipping for items is changed to 2 decimal points and it causes the item price to sometimes have a 1 cent increase or decrease in price. Example:

    shipping is: 2.01613 and when calculate_shipping function is triggered this value changes to 2.02. The solution would be to:

    
    add_filter('woocommerce_order_get_items', 'xonja_woo_fix_shipping_tax', 1);
    
    function xonja_woo_fix_shipping_tax($items) {
        foreach ($items as $item) {
            /* @var $item WC_Order_Item_Shipping */
            if ($item instanceof WC_Order_Item_Shipping) {
                ($item->set_total(2.01613, 4));
            }
        }
        return $items;
    }
    

    but $item->set_total does not accept the second parameter ($dp).
    To do this WC_Order_Item_Shipping would need a slight change:

    
    public function set_total( $value, $dp = 2 ) {
    		$this->set_prop( 'total', wc_format_decimal( $value, $dp ) );
    }
    

    Any body found a work around to this?

  • The topic ‘_order_shipping is formated to 2 decimal points’ is closed to new replies.