Customer number in pdf invoice plugin

  • Posts: 20
  • Thank you received: 0
5 years 4 months ago #301911

-- HikaShop version -- : 4.0.1
-- Joomla version -- : 3.9.1
-- PHP version -- : 7.2.12
-- Browser(s) name and version -- : Firefox 65.0b5

Hello,
I have configured the pdf invoice plugin to send the invoice with confirmation email. It works well but I have an issue :
I need to display a customer number in the ivoice. This number is made of 2 fields :

  1. custom field I called user type that has 2 possible values
  2. the hikashop user id
I manage to make it work when I request the invoice from the backend (click on invoice in order administration) But it doesn't work when the invoice is sent by mail and returns 000000
This is the code I user to display the number in attachinvoice/attachinvoice/invoice.php :
    <?php
    $user = hikashop_loadUser(true);
    $userType = $user->user_type;
    $userHikashopId = $user->user_id;
    $codeClient = $userType . str_pad($userHikashopId, 6, '0', STR_PAD_LEFT);
    ?>
    <br/>
    Code client : <?php echo $codeClient; ?>

I suppose I can't use hikashop_loadUser(true) at that point so how can I get the info to build my customer number?

Last edit: 5 years 4 months ago by web-tiki.

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
5 years 4 months ago #301922

hikashop_loadUser is only to load the data of the user currently logged in.
Instead, you want to do that:

$userClass = hikashop_get('class.user');
$user = $userClass->get($order->order_user_id);

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

  • Posts: 20
  • Thank you received: 0
5 years 4 months ago #301938

Thank you very much. This works as expected.

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

Time to create page: 0.058 seconds
Powered by Kunena Forum