Add fields from Payment Plugin to CSV Export

  • Posts: 57
  • Thank you received: 1
8 years 3 months ago #247119

-- HikaShop version -- : HikaShop Business: 2.6.3
-- Joomla version -- : 3.6
-- PHP version -- : 5.6

Hey

When using Purchase Order payment method there an input box for the order number. Also, I have added to it another inout box called The Workflow Code. I have managed to pass the values to the order, the confirmation emails and to the invoice but can't find how to add those 2 fields to the CSV Export file...

Ideas?

Thanks

Attachments:

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
8 years 3 months ago #247122

Hi,

The plugin "purchase order" store his data in the order history ; that data is not include in the order export.
With recent features in HikaShop, I think that the "order_payment_params" could be a better place to let that plugin store his data.

The idea would be to update the plugin and replace

$history->data = JText::_('PURCHASE_ORDER_NUMBER').@$_SESSION['hikashop_purchase_order_number'];
By
$history->data = JText::_('PURCHASE_ORDER_NUMBER').@$_SESSION['hikashop_purchase_order_number'];
if(empty($order->order_payment_params))
	$order->order_payment_params = new stdClass();
$order->order_payment_params->purchase_order = @$_SESSION['hikashop_purchase_order_number'];
And then you will also find the purchase order data in the order export (encapsulated but the information will be there).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 57
  • Thank you received: 1
8 years 3 months ago #247209

Hey Jerome

Thanks for your reply.

Added the changed in the code as you suggested :

$history->data = JText::_('PURCHASE_ORDER_NUMBER').@$_SESSION['hikashop_purchase_order_number'];
if(empty($order->order_payment_params))
	$order->order_payment_params = new stdClass();
$order->order_payment_params->purchase_order = @$_SESSION['hikashop_purchase_order_number']
."<br> The Work Flow Code : ".@$_SESSION['hikashop_account_holder_number'];

Still can't find this info in the CSV file.

Ideas?

Cheers

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 3 months ago #247214

Hi,

You'll only see that for new orders after you did the change. For older ones, there is no easy solution besides complex custom code.

Did you try after some new orders ?
Could you provide a copy of the resulting CSV ?

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

  • Posts: 57
  • Thank you received: 1
8 years 3 months ago #247592

Hey Nicolas,

Almost there... ;)

First, I have added a custom field to the plugin called 'The Workflow Code' - see attached.
I can see both fields on the order page in the backend and they are also being sent to the admin order creation email.

But in the report I can only see the order number field in a very strange format - see attached. And the custom field doesn't appear to be in the report at all.

My code looks like that :

function needCC(&$method){
	$method->custom_html='<span style="margin-left:10%">'.JText::_('PURCHASE_ORDER_NUMBER').
		'<input type="text" class="hikashop_purchase_order_number inputbox required" name="hikashop_purchase_order_number" value="'.@$_SESSION['hikashop_purchase_order_number'].'"/> *</span><br /><br /><span style="margin-left:10%">'.
		JText::_('The Workflow Code: ').'<input type="text" class="hikashop_account_holder_number inputbox required" name="hikashop_account_holder_number" value="'.@$_SESSION['hikashop_account_holder_number'].'"/> *</span>';
}

function onPaymentSave(&$cart, &$rates, &$payment_id) {
	$_SESSION['hikashop_purchase_order_number'] = JRequest::getVar('hikashop_purchase_order_number');
	$_SESSION['hikashop_account_holder_number'] = JRequest::getVar('hikashop_account_holder_number');

And added your suggested code :
$history->data = JText::_('PURCHASE_ORDER_NUMBER').@$_SESSION['hikashop_purchase_order_number'].
	"<br> The Workflow Code : ".@$_SESSION['hikashop_account_holder_number'];
if(empty($order->order_payment_params))
	$order->order_payment_params = new stdClass();
$order->order_payment_params->purchase_order = @$_SESSION['hikashop_purchase_order_number'];

Ideas?

Thanks

Attachments:
Last edit: 8 years 3 months ago by Jerome. Reason: cleaning code

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 3 months ago #247606

Hi,

As Jerome said, the information is

encapsulated but the information will be there

in the report.
If you want it as its own column, then create a custom field of the table "order" via the menu Display>Custom fields and replace the line:
$order->order_payment_params->purchase_order = @$_SESSION['hikashop_purchase_order_number'];
by:
$order->XXX = @$_SESSION['hikashop_purchase_order_number'];
where XXX is the column name of your custom field.
You'll then get your value is a separate column with its title being the column name of your custom field.

The following user(s) said Thank You: tariaki

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

Time to create page: 0.067 seconds
Powered by Kunena Forum