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

#   How to know total orders without tax

##

- **[andreasuriani](/forum/user/28733-andreasuriani "View andreasuriani's Profile")**
- [![andreasuriani's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar28733.jpg)](/forum/user/28733-andreasuriani "View andreasuriani's Profile") Topic Author
- [ Offline](/forum/user/28733-andreasuriani)

Less More

- Posts: 177
- Thank you received: 1
-
-

9 years 5 months ago [\#270505](#270505) by [andreasuriani](/forum/user/28733-andreasuriani "View andreasuriani's Profile")  *[How to know total orders without tax](/forum/31-development/890434-how-to-know-total-orders-without-tax#270505 "-- HikaShop version -- : 3.1.0 -- Joomla version -- : latest  Hi guys, i need to know trough SQL query how many orders i have in my db and calculate the total amount.  Looking inside db i discover that in the table &#95;hikashop&#95;order there is only the column named &quot;order&#95;full&#95;price&quot; that include all taxes. Is it right? How can i know the total without taxes?  My query is:")* was created by *[andreasuriani](/forum/user/28733-andreasuriani "View andreasuriani's Profile")*

-- HikaShop version -- : 3.1.0
-- Joomla version -- : latest

Hi guys,
i need to know trough SQL query how many orders i have in my db and calculate the total amount.

Looking inside db i discover that in the table _hikashop_order there is only the column named "order_full_price" that include all taxes. Is it right?
How can i know the total without taxes?

My query is:
Code:

SELECT SUM(order_full_price) FROM &#96;#####_hikashop_order&#96; WHERE order_status = "confirmed"

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5MDQzNC1ob3ctdG8ta25vdy10b3RhbC1vcmRlcnMtd2l0aG91dC10YXg/dG1wbD1tYXJrZG93bg==) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86359
- Thank you received: 14293
-
-

9 years 5 months ago [\#270512](#270512) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to know total orders without tax](/forum/31-development/890434-how-to-know-total-orders-without-tax#270512 "-- HikaShop version -- : 3.1.0 -- Joomla version -- : latest  Hi guys, i need to know trough SQL query how many orders i have in my db and calculate the total amount.  Looking inside db i discover that in the table &#95;hikashop&#95;order there is only the column named &quot;order&#95;full&#95;price&quot; that include all taxes. Is it right? How can i know the total without taxes?  My query is:")*

Hi,

There is no such data readily available in the database.
You would have to load the order_tax_info data, json_decode it, sum the different tax_amounts and substract the sum on the order_full_price.
If you have only one tax_amount per order all the time, you could do it in MySQL with some regex if it's imperative that it would be done in MySQL only.

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

- **[andreasuriani](/forum/user/28733-andreasuriani "View andreasuriani's Profile")**
- [![andreasuriani's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar28733.jpg)](/forum/user/28733-andreasuriani "View andreasuriani's Profile") Topic Author
- [ Offline](/forum/user/28733-andreasuriani)

Less More

- Posts: 177
- Thank you received: 1
-
-

9 years 5 months ago [\#270555](#270555) by [andreasuriani](/forum/user/28733-andreasuriani "View andreasuriani's Profile")  Replied by *[andreasuriani](/forum/user/28733-andreasuriani "View andreasuriani's Profile")* on topic *[How to know total orders without tax](/forum/31-development/890434-how-to-know-total-orders-without-tax#270555 "-- HikaShop version -- : 3.1.0 -- Joomla version -- : latest  Hi guys, i need to know trough SQL query how many orders i have in my db and calculate the total amount.  Looking inside db i discover that in the table &#95;hikashop&#95;order there is only the column named &quot;order&#95;full&#95;price&quot; that include all taxes. Is it right? How can i know the total without taxes?  My query is:")*

Hi Nicolas,
any help for the code?

I don't know hot to start to do it...

Thanks

Andrea

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5MDQzNC1ob3ctdG8ta25vdy10b3RhbC1vcmRlcnMtd2l0aG91dC10YXg/dG1wbD1tYXJrZG93bg==) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86359
- Thank you received: 14293
-
-

9 years 5 months ago [\#270556](#270556) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to know total orders without tax](/forum/31-development/890434-how-to-know-total-orders-without-tax#270556 "-- HikaShop version -- : 3.1.0 -- Joomla version -- : latest  Hi guys, i need to know trough SQL query how many orders i have in my db and calculate the total amount.  Looking inside db i discover that in the table &#95;hikashop&#95;order there is only the column named &quot;order&#95;full&#95;price&quot; that include all taxes. Is it right? How can i know the total without taxes?  My query is:")*

Run the query:
SELECT * FROM &#96;#__hikashop_order&#96; WHERE order_status = "confirmed"
the you get an array of orders in PHP.
You loop on them like that: Code:

$total without tax = 0; foreach($orders as $order){ $taxes = reset(json_decode($order-&gt;order_tax_info)); $total without tax+= $order-&gt;order_full_price - $taxes-&gt;tax_amount; } echo $total without tax;

Of course that code is not tested. It's just an example of what it should look like. Please understand that this is outside the scope of our support.

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

- **[andreasuriani](/forum/user/28733-andreasuriani "View andreasuriani's Profile")**
- [![andreasuriani's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar28733.jpg)](/forum/user/28733-andreasuriani "View andreasuriani's Profile") Topic Author
- [ Offline](/forum/user/28733-andreasuriani)

Less More

- Posts: 177
- Thank you received: 1
-
-

9 years 5 months ago -  9 years 5 months ago [\#270897](#270897) by [andreasuriani](/forum/user/28733-andreasuriani "View andreasuriani's Profile")  Replied by *[andreasuriani](/forum/user/28733-andreasuriani "View andreasuriani's Profile")* on topic *[How to know total orders without tax](/forum/31-development/890434-how-to-know-total-orders-without-tax#270897 "-- HikaShop version -- : 3.1.0 -- Joomla version -- : latest  Hi guys, i need to know trough SQL query how many orders i have in my db and calculate the total amount.  Looking inside db i discover that in the table &#95;hikashop&#95;order there is only the column named &quot;order&#95;full&#95;price&quot; that include all taxes. Is it right? How can i know the total without taxes?  My query is:")*

HI , sorry to be late.

I've tested this code:
Code:

&lt;?php $db = JFactory::getDbo(); $result = $db-&gt;setQuery("SELECT * FROM &#96;*****_hikashop_order&#96; WHERE order_status = 'confirmed'")-&gt;loadObject(); $total_without_tax = 0; foreach($orders as $order){ $taxes = reset(json_decode($order-&gt;order_tax_info)); $total_without_tax+= $order-&gt;order_full_price - $taxes-&gt;tax_amount; } echo $total_without_tax; ?&gt;

The output is 0 but is not true....

Any help ? ![:(](/media/kunena/emoticons/22.png ":(")

Last edit: 9 years 5 months ago by [andreasuriani](/forum/user/28733-andreasuriani "View andreasuriani's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5MDQzNC1ob3ctdG8ta25vdy10b3RhbC1vcmRlcnMtd2l0aG91dC10YXg/dG1wbD1tYXJrZG93bg==) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86359
- Thank you received: 14293
-
-

9 years 5 months ago [\#270901](#270901) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to know total orders without tax](/forum/31-development/890434-how-to-know-total-orders-without-tax#270901 "-- HikaShop version -- : 3.1.0 -- Joomla version -- : latest  Hi guys, i need to know trough SQL query how many orders i have in my db and calculate the total amount.  Looking inside db i discover that in the table &#95;hikashop&#95;order there is only the column named &quot;order&#95;full&#95;price&quot; that include all taxes. Is it right? How can i know the total without taxes?  My query is:")*

Hi,

Please understand that we're not here to help you with PHP coding.
This is basic PHP...
The query results are stored in $result in your code, so you need to replace $orders by $result in your code.
Also, you're using loadObject which only returns one result instead of loadObjectList which will return all of them.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5MDQzNC1ob3ctdG8ta25vdy10b3RhbC1vcmRlcnMtd2l0aG91dC10YXg/dG1wbD1tYXJrZG93bg==) 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.056 seconds

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