Show custom field in invoices

  • Posts: 124
  • Thank you received: 6
3 years 3 months ago #335154

-- HikaShop version -- : 4.4.3
-- Joomla version -- : 3.9.27
-- PHP version -- : 5.6

Hi
I create a custom field with name "user_code_melli" in user table (attached picture 1).
I add this to invoices in hikashop config -> main -> Checkout tab -> ADDRESS & SHIPPING section (attached picture 2).

{user_code_melli}
but don't show anything.
Thanks for your help

Attachments:

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

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

Hi,

You can only use custom fields of the "address" table in the "address format" setting.

If you want to add a custom user field in the invoice that you can get with the "invoice" button of your backend, you need to edit the file order / invoice.php via the menu Display>Views and add such code:

<?php echo $this->element->customer->xxx; ?>
where xxx is to be replaced by the column name of your custom user field "user_code_melli".

The following user(s) said Thank You: levelup

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

  • Posts: 124
  • Thank you received: 6
2 years 10 months ago #338812

Hi
I did this before in HikaShop 4.2.2 and it worked. But it seems that in HikaShop 4.4.5 has changed in Joomla 4. I can not find order / invoice.php via the menu Display>Views.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 10 months ago #338818

Hi,

It's still there though.
Please double check.
Note also that you have filters on the top right corner of the listing.
If you have a filter on the frontend template, you won't see the view files of the backend like this one for example.

The following user(s) said Thank You: levelup

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

  • Posts: 124
  • Thank you received: 6
2 years 10 months ago #338839

i want show user custom field in front end invoice.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 10 months ago #338851

Hi,

What I gave before on this thread was for the invoice available in the backend.
For the invoice in the frontend, you need to do the same modification but in the view file order / show.php for your frontend template.

The following user(s) said Thank You: levelup

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

  • Posts: 124
  • Thank you received: 6
2 years 8 months ago #339950

Hi
i was create user custom field named user_code_melli and want to show in backend-> order-> edit in Customer section. How can I do this? I think I should change the order/show_user.php file.
I used this

<tr><td><?php echo $this->user->user_code_melli ?>{user_code_melli}</td></tr>
and that
<tr><td><?php echo JText::_('USER_CODE_MELLI').': '.$this->element->customer->user_code_melli; ?></td></tr>
But it does not work. what code should I use?

Last edit: 2 years 8 months ago by levelup.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 8 months ago #339957

Hi,

Check the code already in order / show_user.php
You can see this line:

<td><span id="hikashop_order_customer_name"><?php echo @$this->order->customer->name; ?></span></td>
or this one:
<td><span id="hikashop_order_customer_email"><?php echo @$this->order->customer->user_email; ?></span></td>
So you can see that the user data is in $this->order->customer
So you can do this:
<tr class="hikashop_order_customer_melli">
		<td class="key"><label><?php echo JText::_('USER_CODE_MELLI');?></label></td>
		<td><span id="hikashop_order_customer_melli"><?php echo @$this->order->customer->user_code_melli; ?></span></td>
</tr>

Last edit: 2 years 8 months ago by nicolas.
The following user(s) said Thank You: levelup

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

Time to create page: 0.070 seconds
Powered by Kunena Forum