Customize Orders Export

  • Posts: 14
  • Thank you received: 1
2 years 11 months ago #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:

 * @package	HikaShop for Joomla!
 * @version	2.6.2
 * @author
 * @copyright	(C) 2010-2016 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3
defined('_JEXEC') or die('Restricted access');
while(ob_get_level() > 1)

$config =& hikashop_config();
$format = $config->get('export_format','csv');
$separator = $config->get('csv_separator',';');
$force_quote = $config->get('csv_force_quote',1);
$decimal_separator = $config->get('csv_decimal_separator','.');

$export = hikashop_get('helper.spreadsheet');
$export->init($format, 'hikashop_export', $separator, $force_quote, $decimal_separator);

	$maxProd = 0;
	$productFields = null;
	foreach($this->orders as $order){
		$nbProd = count(@$order->products);
		if($maxProd < $nbProd){
			$maxProd = $nbProd;
				$productFields = array_keys(get_object_vars(reset($order->products)));

	if($maxProd && !empty($productFields)) {
		$first = array();
		$o = reset($this->orders);
		foreach($o as $key => $val) {
			$first[] = $key;
		$o = null;
			foreach($productFields as $field){
				$first[] = 'item'.$i.'_'.$field;
	} else {
		$first = array_keys(get_object_vars(reset($this->orders)));

	foreach($this->orders as $row)
		//format date
		if(!empty($row->user_created)) $row->user_created = hikashop_getDate($row->user_created,'%m-%d-%Y ');
		if(!empty($row->order_created)) $row->order_created = hikashop_getDate($row->order_created,'%m-%d-%Y');
		if(!empty($row->order_modified)) $row->order_modified = hikashop_getDate($row->order_modified,'%m-%d-%Y');
		$new_row = array();
		foreach ($row as $key => $value)  
			$new_row[$key] = $value;


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


Please Log in or Create an account to join the conversation.

  • Posts: 65630
  • Thank you received: 9578
2 years 11 months ago #241390


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:

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->$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 or Create an account to join the conversation.

Time to create page: 0.055 seconds
Powered by Kunena Forum