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

#   Customize Orders Export

##

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

Less More

- Posts: 14
- Thank you received: 1
-
-

10 years 4 months ago [\#241382](#241382) by [midnites](/forum/user/32921-midnites "View midnites's Profile")  *[Customize Orders Export](/forum/36-reports-statistics/884770-customize-orders-export#241382 "-- HikaShop version -- : 2.6.2 -- Joomla version -- : 3.5.2  Through another post I was able to figure out how to only pull the data I need for the Orders Export (Mass action does not work for what I need!). I have 4 issues:  1) I need to export the subtotal before tax (same as appears under the individual order Additional Information box). 2) I need to rearrange column order. 3) Change column headers. 4) I also need to pull in coupons and I can't find the variable name for that.  (I am NOT a php programmer, but I understand it a little). Here's my updated export code:  I've attached a screen cap of what it's outputting. Thanks!")* was created by *[midnites](/forum/user/32921-midnites "View midnites's Profile")*

-- HikaShop version -- : 2.6.2
-- Joomla version -- : 3.5.2

Through another post I was able to figure out how to only pull the data I need for the Orders Export (Mass action does not work for what I need!). I have 4 issues:

1) I need to export the subtotal before tax (same as appears under the individual order Additional Information box).
2) I need to rearrange column order.
3) Change column headers.
4) I also need to pull in coupons and I can't find the variable name for that.

(I am NOT a php programmer, but I understand it a little).
Here's my updated export code:
Code:

&lt;?php /** * @package HikaShop for Joomla! * @version 2.6.2 * @author hikashop.com * @copyright (C) 2010-2016 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php while(ob_get_level() &gt; 1) ob_end_clean(); $config =&amp; hikashop_config(); $format = $config-&gt;get('export_format','csv'); $separator = $config-&gt;get('csv_separator',';'); $force_quote = $config-&gt;get('csv_force_quote',1); $decimal_separator = $config-&gt;get('csv_decimal_separator','.'); $export = hikashop_get('helper.spreadsheet'); $export-&gt;init($format, 'hikashop_export', $separator, $force_quote, $decimal_separator); if(!empty($this-&gt;orders)){ $maxProd = 0; $productFields = null; foreach($this-&gt;orders as $order){ $nbProd = count(@$order-&gt;products); if($maxProd &lt; $nbProd){ $maxProd = $nbProd; if(empty($productFields)){ $productFields = array_keys(get_object_vars(reset($order-&gt;products))); } } } if($maxProd &amp;&amp; !empty($productFields)) { $first = array(); $o = reset($this-&gt;orders); foreach($o as $key =&gt; $val) { if(is_array($val)) continue; $first[] = $key; } $o = null; for($i=1;$i&lt;=$maxProd;$i++){ foreach($productFields as $field){ $first[] = 'item'.$i.'_'.$field; } } } else { $first = array_keys(get_object_vars(reset($this-&gt;orders))); } $export-&gt;writeLine($first); foreach($this-&gt;orders as $row) { //format date if(!empty($row-&gt;user_created)) $row-&gt;user_created = hikashop_getDate($row-&gt;user_created,'%m-%d-%Y '); if(!empty($row-&gt;order_created)) $row-&gt;order_created = hikashop_getDate($row-&gt;order_created,'%m-%d-%Y'); if(!empty($row-&gt;order_modified)) $row-&gt;order_modified = hikashop_getDate($row-&gt;order_modified,'%m-%d-%Y'); //info $new_row = array(); foreach ($row as $key =&gt; $value) { if(in_array($key,array('order_number','order_modified','shipping_address_city','shipping_address_state','order_subtotal_no_vat','order_discount_price','order_shipping_price','order_full_tax','order_full_price'))) $new_row[$key] = $value; } $export-&gt;writeLine($new_row); } } $export-&gt;send(); exit;

I've attached a screen cap of what it's outputting.
Thanks!

- [ ![output.jpg](/forum/attachment/31695) ](/forum/attachment/31695 "output.jpg") [ ](/forum/attachment/31695?download=1 "output.jpg")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM2LXJlcG9ydHMtc3RhdGlzdGljcy84ODQ3NzAtY3VzdG9taXplLW9yZGVycy1leHBvcnQ/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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

10 years 4 months ago [\#241390](#241390) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Customize Orders Export](/forum/36-reports-statistics/884770-customize-orders-export#241390 "-- HikaShop version -- : 2.6.2 -- Joomla version -- : 3.5.2  Through another post I was able to figure out how to only pull the data I need for the Orders Export (Mass action does not work for what I need!). I have 4 issues:  1) I need to export the subtotal before tax (same as appears under the individual order Additional Information box). 2) I need to rearrange column order. 3) Change column headers. 4) I also need to pull in coupons and I can't find the variable name for that.  (I am NOT a php programmer, but I understand it a little). Here's my updated export code:  I've attached a screen cap of what it's outputting. Thanks!")*

Hi,

Please note that we offer user support here, not free custom development services.
So we can answer questions about how to use HikaShop, and fix issues, but such work ought to be given to a developer you'd hire for that.
As I'm nice, I'll give you hints to what you want to do.

1. You would have to manually calculate it out of the product prices similarily to was is done for the calculation of the order_full_tax in the export function of the file administrator/components/com_hikashop/views/order/view.html.php

2. and 3. You want to change your code for the creation of the $new_row and do the foreach on your array of column names (with them in the order you want). Something like that: Code:

foreach(array('order_number','order_modified','shipping_address_city','shipping_address_state','order_subtotal_no_vat','order_discount_price','order_shipping_price','order_full_tax','order_full_price') as $column){ $new_row[$column] = $row-&gt;$column; }

And you want to change $first to contain the array of the column names you want in the order you want them.

4. The coupon code is stored in order_discount_code

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM2LXJlcG9ydHMtc3RhdGlzdGljcy84ODQ3NzAtY3VzdG9taXplLW9yZGVycy1leHBvcnQ/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.118 seconds

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

[](#top)
