[Skip to main content](#vessel-content)

#   Roundoff the total amount ofter delivery charge

##

- **[danny1117](/forum/user/71939-danny1117 "View danny1117's Profile")**
- [![danny1117's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/71939-danny1117 "View danny1117's Profile") Topic Author
- [ Offline](/forum/user/71939-danny1117)

Less More

- Posts: 3
- Thank you received: 0
-
-

3 years 9 months ago [\#349541](#349541) by [danny1117](/forum/user/71939-danny1117 "View danny1117's Profile")  *[Roundoff the total amount ofter delivery charge](/forum/25-install-update/905949-roundoff-the-total-amount-ofter-delivery-charge#349541 "-- url of the page with the problem -- :   odc.com.my  -- Joomla version -- : 3  Dear hikashop, How should I do if wanna take the total (rounded off price) to add the delivery charge instead of the subtotal.")* was created by *[danny1117](/forum/user/71939-danny1117 "View danny1117's Profile")*

-- url of the page with the problem -- : [ odc.com.my](https://odc.com.my)
-- Joomla version -- : 3

Dear hikashop,
How should I do if wanna take the total (rounded off price) to add the delivery charge instead of the subtotal.

- [ ![Capture&#95;2023-02-24.PNG](/forum/attachment/56575) ](/forum/attachment/56575 "...2023-02-24.PNG") [ ](/forum/attachment/56575?download=1 "...2023-02-24.PNG")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzkwNTk0OS1yb3VuZG9mZi10aGUtdG90YWwtYW1vdW50LW9mdGVyLWRlbGl2ZXJ5LWNoYXJnZT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86593
- Thank you received: 14334
-
-

3 years 9 months ago [\#349544](#349544) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Roundoff the total amount ofter delivery charge](/forum/25-install-update/905949-roundoff-the-total-amount-ofter-delivery-charge#349544 "-- url of the page with the problem -- :   odc.com.my  -- Joomla version -- : 3  Dear hikashop, How should I do if wanna take the total (rounded off price) to add the delivery charge instead of the subtotal.")*

Hi,

I'm not sure I understand what you want.
Maybe you want to activate the "round prices during calculations" so that the subtotal and total are the same when there is no shipping/coupon/payment ?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzkwNTk0OS1yb3VuZG9mZi10aGUtdG90YWwtYW1vdW50LW9mdGVyLWRlbGl2ZXJ5LWNoYXJnZT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[danny1117](/forum/user/71939-danny1117 "View danny1117's Profile")**
- [![danny1117's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/71939-danny1117 "View danny1117's Profile") Topic Author
- [ Offline](/forum/user/71939-danny1117)

Less More

- Posts: 3
- Thank you received: 0
-
-

3 years 9 months ago [\#349547](#349547) by [danny1117](/forum/user/71939-danny1117 "View danny1117's Profile")  Replied by *[danny1117](/forum/user/71939-danny1117 "View danny1117's Profile")* on topic *[Roundoff the total amount ofter delivery charge](/forum/25-install-update/905949-roundoff-the-total-amount-ofter-delivery-charge#349547 "-- url of the page with the problem -- :   odc.com.my  -- Joomla version -- : 3  Dear hikashop, How should I do if wanna take the total (rounded off price) to add the delivery charge instead of the subtotal.")*

Dear Hikashop,
In site, the order's total will be rounded off automatically as full order price. However, if admin edits order in backend, all order products will be recalculated in fucntion recalculateFullPrice(&amp;$order, $products = null), then the $order-&gt;order_full_price will not be rounded with 1 decimal, example RM 100.16 shoud be RM 100.20. Can I modify the code in the recalculateFullPrice function by adding ($order-&gt;order_full_price = round($order-&gt;order_full_price,1)![;)](/media/kunena/emoticons/24.png ";)")?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzkwNTk0OS1yb3VuZG9mZi10aGUtdG90YWwtYW1vdW50LW9mdGVyLWRlbGl2ZXJ5LWNoYXJnZT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86593
- Thank you received: 14334
-
-

3 years 9 months ago [\#349558](#349558) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Roundoff the total amount ofter delivery charge](/forum/25-install-update/905949-roundoff-the-total-amount-ofter-delivery-charge#349558 "-- url of the page with the problem -- :   odc.com.my  -- Joomla version -- : 3  Dear hikashop, How should I do if wanna take the total (rounded off price) to add the delivery charge instead of the subtotal.")*

Hi,

Well, you can but that's not a long term solution as you would need to do the change after each update.
It would be better for us to properly understand the situation, in order to add an appropriate patch so that no modification is necessary on your end.

How is the rounding to 1 decimal done on your frontend ?
Is this something you configured in your currency settings ?
Could you provide a screenshot of that ?
What is the status of the setting "round prices during calculations" ?
What is the price of each product and its quantity in the order ?

I've looked into this recalculateFullPrice function's code and I think such code should do the job: Code:

public function recalculateFullPrice(&amp;$order, $products = null) { //load all the prices and recalculate total if(empty($products)) { $query = 'SELECT * FROM '.hikashop_table('order_product').' WHERE order_id = ' . (int)$order-&gt;order_id; $this-&gt;database-&gt;setQuery($query); $products = $this-&gt;database-&gt;loadObjectList(); } $total = 0.0; $taxes = array(); $bases = array(); JPluginHelper::importPlugin('hikashop'); $app = JFactory::getApplication(); if(empty($order-&gt;old) &amp;&amp; !empty($order-&gt;order_id)) { $order-&gt;old = $this-&gt;get($order-&gt;order_id); } $old = @$order-&gt;old; $rounding = 2; $currencyClass = hikashop_get('class.currency'); if(!empty($old-&gt;order_currency_id)) { $rounding = $currencyClass-&gt;getRounding($old-&gt;order_currency_id, true); } foreach($products as $i =&gt; $product) { if($product-&gt;order_product_code != 'order additional') { $app-&gt;triggerEvent( 'onBeforeCalculateProductPriceForQuantityInOrder', array( &amp;$products[$i]) ); if(function_exists('hikashop_product_price_for_quantity_in_order')) { hikashop_product_price_for_quantity_in_order($product); } else { $product-&gt;order_product_total_price = ((float)$product-&gt;order_product_price + (float)$product-&gt;order_product_tax) * (int)$product-&gt;order_product_quantity; } $app-&gt;triggerEvent('onAfterCalculateProductPriceForQuantityInOrder', array( &amp;$products[$i]) ); } else { $product-&gt;order_product_total_price = ((float)$product-&gt;order_product_price + (float)$product-&gt;order_product_tax); } $total += $currencyClass-&gt;round($product-&gt;order_product_total_price, $rounding); // Recalculate taxes for that product line if(!empty($product-&gt;order_product_tax_info)) { if(is_string($product-&gt;order_product_tax_info)) $product_taxes = hikashop_unserialize($product-&gt;order_product_tax_info); else $product_taxes = $product-&gt;order_product_tax_info; foreach($product_taxes as $tax) { if(!isset($taxes[$tax-&gt;tax_namekey])) { $taxes[$tax-&gt;tax_namekey] = 0; $bases[$tax-&gt;tax_namekey] = 0; } if($product-&gt;order_product_code == 'order additional') { $taxes[$tax-&gt;tax_namekey] += (float)@$tax-&gt;tax_amount; $bases[$tax-&gt;tax_namekey] += (float)@$tax-&gt;amount; } else { $taxes[$tax-&gt;tax_namekey] += (float)@$tax-&gt;tax_amount * $product-&gt;order_product_quantity; $bases[$tax-&gt;tax_namekey] += (float)@$tax-&gt;amount * $product-&gt;order_product_quantity; } } } } if(!isset($order-&gt;order_discount_price)) $order-&gt;order_discount_price = @$old-&gt;order_discount_price; if(!isset($order-&gt;order_shipping_price)) $order-&gt;order_shipping_price = @$old-&gt;order_shipping_price; if(!isset($order-&gt;order_payment_price)) $order-&gt;order_payment_price = @$old-&gt;order_payment_price; $additionals = 0 - $currencyClass-&gt;round((float)$order-&gt;order_discount_price, $round) + $currencyClass-&gt;round((float)$order-&gt;order_shipping_price, $round) + $currencyClass-&gt;round((float)$order-&gt;order_payment_price, $round); $order-&gt;order_full_price = $total + $additionals; if($order-&gt;order_full_price &lt; 0 &amp;&amp; $total &gt; 0) $order-&gt;order_full_price = 0; //recalculate total taxes $config =&amp; hikashop_config(); if(!isset($order-&gt;order_tax_info) &#124;&#124; empty($order-&gt;order_tax_info)) { if(!empty($old-&gt;order_tax_info)) { $order-&gt;order_tax_info = $old-&gt;order_tax_info; } elseif($config-&gt;get('detailed_tax_display', 1)) { $order-&gt;order_tax_info = array(); } } if(!empty($order-&gt;order_tax_info) &#124;&#124; $config-&gt;get('detailed_tax_display', 1)) { if(is_string($order-&gt;order_tax_info)) $order-&gt;order_tax_info = hikashop_unserialize($order-&gt;order_tax_info); if(count($order-&gt;order_tax_info)){ foreach($order-&gt;order_tax_info as $k =&gt; $tax) { $order-&gt;order_tax_info[$k]-&gt;todo = true; } } if(!empty($taxes)) { foreach($taxes as $namekey =&gt; $amount) { $found = false; foreach($order-&gt;order_tax_info as $k =&gt; $tax) { if($tax-&gt;tax_namekey == $namekey) { $tax_additionals = @$tax-&gt;tax_amount_for_shipping + @$tax-&gt;tax_amount_for_payment - @$tax-&gt;tax_amount_for_coupon; $gross_additionals = $tax_additionals - $order-&gt;order_discount_price + $order-&gt;order_shipping_price + $order-&gt;order_payment_price; $order-&gt;order_tax_info[$k]-&gt;tax_amount = $amount + $tax_additionals; $order-&gt;order_tax_info[$k]-&gt;amount = $bases[$namekey] + $gross_additionals; if($order-&gt;order_full_price == 0) { $order-&gt;order_tax_info[$k]-&gt;tax_amount = 0; $order-&gt;order_tax_info[$k]-&gt;amount = 0; } unset($order-&gt;order_tax_info[$k]-&gt;todo); $found = true; break; } } if(!$found) { $obj = new stdClass(); $obj-&gt;tax_namekey = $namekey; $obj-&gt;tax_amount = $amount; $obj-&gt;amount = $bases[$namekey]; if($order-&gt;order_full_price == 0) { $obj-&gt;tax_amount = 0; $obj-&gt;amount = 0; } $order-&gt;order_tax_info[$namekey] = $obj; } } } $unset = array(); foreach($order-&gt;order_tax_info as $k =&gt; $tax) { if(isset($tax-&gt;todo)) { $tax_additionals = @$tax-&gt;tax_amount_for_shipping + @$tax-&gt;tax_amount_for_payment - @$tax-&gt;tax_amount_for_coupon; $gross_additionals = $tax_additionals - $order-&gt;order_discount_price + $order-&gt;order_shipping_price + $order-&gt;order_payment_price; $order-&gt;order_tax_info[$k]-&gt;tax_amount = $tax_additionals; $order-&gt;order_tax_info[$k]-&gt;amount = $gross_additionals; if($order-&gt;order_full_price == 0) { $order-&gt;order_tax_info[$k]-&gt;tax_amount = 0; $order-&gt;order_tax_info[$k]-&gt;amount = 0; } if(!bccomp(sprintf('%F',$order-&gt;order_tax_info[$k]-&gt;tax_amount),0,5)) { $unset[]=$k; } else { unset($order-&gt;order_tax_info[$k]-&gt;todo); } } } if(!empty($unset)) { foreach($unset as $u) { unset($order-&gt;order_tax_info[$u]); } } } }

So you could copy/paste it instead of the current code and see if that helps. But I can't say it will work for sure as I'm not able to reproduce the problem on my end as I don't have yet the necessary information for that.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzkwNTk0OS1yb3VuZG9mZi10aGUtdG90YWwtYW1vdW50LW9mdGVyLWRlbGl2ZXJ5LWNoYXJnZT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.060 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
