Title: Problem COD order amount
Last modified: December 28, 2020

---

# Problem COD order amount

 *  [fellter2](https://wordpress.org/support/users/fellter2/)
 * (@fellter2)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/problem-cod-order-amount/)
 * Hi,
    I have a problem with orders that use COD: ue to more accurate price and
   tax calculations, I have set the decimal numbers in Woocommerce to 6. I then 
   added the following function to only display 2 digits in backend and frontened:
 *     ```
       add_filter('wc_price_args', 'custom_decimals_price_args', 10, 1);
       function custom_decimals_price_args($args) {
           $args['decimals'] = 2;
           return $args;
       }
       ```
   
 * But the HL plugin still places 6 digits in the COD order amount and will then
   not create a shippng label. Even if I manually type in an amount with only 2 
   decimals, I am getting the error that no label can be created because there are
   too many decimals…

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Progressus](https://wordpress.org/support/users/shadim/)
 * (@shadim)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/problem-cod-order-amount/#post-13842909)
 * You will likely have to use the filter “pr_shipping_dhl_label_args”, see example
   [https://gist.github.com/shadimanna/b4a6ab1d4f8efcf6061cb5da3bbdb7e4](https://gist.github.com/shadimanna/b4a6ab1d4f8efcf6061cb5da3bbdb7e4).
 * This is the field you need to modify and likely round to 2 decimals – $args[‘
   order_details’][‘cod_value’]
 *  Thread Starter [fellter2](https://wordpress.org/support/users/fellter2/)
 * (@fellter2)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/problem-cod-order-amount/#post-13843599)
 * Thank you, it worked. It still displays 6 digits by default though, so only if
   I now manually set a two digit amount I can create a label. There is no way to
   automatically have the correct amount inserted (that is generated by Woo and 
   has two decimals)?
 *  Plugin Author [Progressus](https://wordpress.org/support/users/shadim/)
 * (@shadim)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/problem-cod-order-amount/#post-13843769)
 * I am not clear on what worked and what did not based on your message. Did you
   use the filter or not?
 *  Thread Starter [fellter2](https://wordpress.org/support/users/fellter2/)
 * (@fellter2)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/problem-cod-order-amount/#post-13843800)
 * Yes, I added the following:
 *     ```
       add_filter('pr_shipping_dhl_label_args', 'modify_order_id_to_number', 10, 2);
       function modify_order_id_to_number($args, $order_id) {
        	$order = wc_get_order( $order_id );
       $args['order_details']['cod_value'] = 2;
       	return $args;
       }
       ```
   
 * and this works in that now I can at least manually enter two decimals and then
   create a label (but the automatically entered amount by the plugin is still 6
   decimals). Before aka without your function I could not even manually enter two
   decimals and thus not create a lable at all.
 *  Plugin Author [Progressus](https://wordpress.org/support/users/shadim/)
 * (@shadim)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/problem-cod-order-amount/#post-13843855)
 * The code you added does not add decimals but the actual value of the COD required.
   So you need to read the order total and round it to 2 decimal points I believe.
 *  Thread Starter [fellter2](https://wordpress.org/support/users/fellter2/)
 * (@fellter2)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/problem-cod-order-amount/#post-13843883)
 * Sorry, my PHP is limited…could you help me with this? In the Woo admin backend
   the totals are already displayed with 2 decimals (due to my function which I 
   posted in my first post).
 *  Plugin Author [Progressus](https://wordpress.org/support/users/shadim/)
 * (@shadim)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/problem-cod-order-amount/#post-13865786)
 * I would recommend you find a PHP developer to help with this customization.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Problem COD order amount’ is closed to new replies.

 * ![](https://ps.w.org/dhl-for-woocommerce/assets/icon.svg?rev=1777040)
 * [DHL Shipping Germany for WooCommerce](https://wordpress.org/plugins/dhl-for-woocommerce/)
 * [Support Threads](https://wordpress.org/support/plugin/dhl-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/dhl-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/dhl-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/dhl-for-woocommerce/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Progressus](https://wordpress.org/support/users/shadim/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/problem-cod-order-amount/#post-13865786)
 * Status: not resolved