User information in Invoice and order number

  • Posts: 20
  • Thank you received: 0
6 years 8 months ago #276095

-- HikaShop version -- : 3.1.1
-- Joomla version -- : 3.7.4
-- PHP version -- : 7.1

Hi,
I need to add information from a custom field (in the user table) to the invoice and order numbers.
Is this possible with HE?

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

  • Posts: 26007
  • Thank you received: 4004
  • MODERATOR
6 years 8 months ago #276097

Hello,

Yes it is possible with HikaShop but it would require a little view override for your invoice view(s) (they are two invoices, one in front end an another for the backend).
www.hikashop.com/support/documentation/1...-display.html#layout

Front-end : order / show
Backend : order / invoice

And you can access to the customer object (and its custom fields) via :

$this->element->customer->...

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.
The following user(s) said Thank You: web-tiki

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

  • Posts: 20
  • Thank you received: 0
6 years 8 months ago #276140

Thx for the answer, I see how to add the information to the invoice and order outputs.
But is it possible to change that number in the backend Where the orders are listed?
I would prefer to have the new order and invoice numbers stored in the database with the user information. Is that possible?
Is there a way to add custom user info in the order and invoice formats?
I saw here

{user user_vat}-{id size="3"}-{date format="m-Y"}
could be used as an order number but the topic is old and I had no succes trying.

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

  • Posts: 26007
  • Thank you received: 4004
  • MODERATOR
6 years 8 months ago #276158

Hello,

Okay ; you want to change the order number format !
Because you were talking about add information to the invoices I thought that you wanted to customized the invoices.

So, yes in HikaShop Essential you can change the format for the "order number" and "invoice number".
And you can use a special tag to access to user data, as you wrote:

{user user_vat}
Now if you want to use something from a user custom field, you need to replace "user_vat" but the namekey of your custom field.
The namekey is also called "column name" :
www.hikashop.com/support/documentation/1...ield-form.html#infos

Afterwards, please note that when you change the format, it will not affect the old orders and you need to create new orders to see the result.

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.
The following user(s) said Thank You: web-tiki

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

  • Posts: 20
  • Thank you received: 0
6 years 8 months ago #276290

Thx for the info. It works fine for the order number but it fails for the invoice number.
This is the format I gave to both of the numbers :

Order number :

{user user_type} - {date format="y m"} {id size="6"}
Invoice number :
{user user_type} - {date format="y m"} {order_id size="6"}

For the invoice number,
{user user_type}
doesn't output anything. Is there a workaround?

Also adding the user info gives an error on the checkout end step (after payement) :
Notice: Undefined property: stdClass::$order_user_id in SOMETHING_HERE\administrator\components\com_hikashop\helpers\helper.php on line 336
I'm testing this out with the cheque payement method.

Last edit: 6 years 8 months ago by web-tiki.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
6 years 8 months ago #276350

Hi,

Thanks for the details. The user tags are indeed no usable in some cases with the invoice number format setting.
Change the code:

$userClass = hikashop_get('class.user');
				$data->customer = $userClass->get($data->order_user_id);
to:
$order_user_id = 0;
				if(isset($data->order_user_id)) {
					$order_user_id = $data->order_user_id;
				} elseif(isset($data->old->order_user_id)) {
					$order_user_id = $data->old->order_user_id;
				} elseif(isset($data->order_id)) {
					$orderClass = hikashop_get('class.order');
					$orderData = $orderClass->get($data->order_id);
					$order_user_id = $orderData->order_user_id;
				}
				if($order_user_id) {
					$userClass = hikashop_get('class.user');
					$data->customer = $userClass->get($order_user_id);
				}
in the file administrator/components/com_hikashop/helpers/helper.php and that will fix the notice message and you'll be able to use the user tags in the invoice number format setting.

The following user(s) said Thank You: web-tiki

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

  • Posts: 20
  • Thank you received: 0
6 years 7 months ago #277048

Perfect thank you, this seems to works fine.
Will this change be pushed in the next hikashop release or will I have to redo this change after each update?

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
6 years 7 months ago #277052

Hi,

Yes, it will be included.

The following user(s) said Thank You: web-tiki

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

  • Posts: 20
  • Thank you received: 0
6 years 7 months ago #277194

Perfect,
Thx Nicolas and Jerome for your support.

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

Time to create page: 0.072 seconds
Powered by Kunena Forum