How to add customer's email address to invoice

  • Posts: 153
  • Thank you received: 7
  • Hikashop Business
12 years 5 months ago #51940

I need to add the customer's email address to the invoice that is generated from the Invoice button while looking at the order. I have found the invoice view in Display->Views that I need to edit, but I am uncertain what code I need to use to pull the email address for the customer.

Anyone know what the code needs to be to accomplish this?

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
12 years 5 months ago #52010

It should be:

<?php echo $this->order->customer->user_email; ?>

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

  • Posts: 153
  • Thank you received: 7
  • Hikashop Business
12 years 5 months ago #52038

Thank you. That worked perfectly.

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

  • Posts: 23
  • Thank you received: 0
11 years 10 months ago #83689

I am trying to add the order # and customers email to the invoice on the backend as well. I know where to find the invoice view in Display>Views, and have tried the code here but don't see any difference. I am not sure if I'm just not adding it in the correct spot. Also can you help me with the code to add the order #.

Last edit: 11 years 10 months ago by Carey.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
11 years 10 months ago #83966

Yes, that's the correct place for the invoice that you can display on the backend. But since it's on the backend, make sure that you're editing it for the template you're using on your backend and not another template. Otherwise, you won't see any change to the invoice.

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

  • Posts: 377
  • Thank you received: 7
10 years 3 months ago #166044

Hi

Does this still work?

I tried adding <?php echo $this->order->customer->user_email; ?> to the invoice.php pdf file and it doesnt return anything, I was hoping to have Dear 'Name' (email), thank you for your purchase...

Kind regards

Alex

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

  • Posts: 2334
  • Thank you received: 403
10 years 3 months ago #166185

Hi Alex,

As Nicolas said previously, are you sure you are editing the file for the right template?
You can simply add a var_dump($this); in the code if you want to see all the variable available.

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

  • Posts: 377
  • Thank you received: 7
10 years 3 months ago #166407

I think this is because i was editing the invoice pdf not the invoice. Kind regards Alex

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
10 years 3 months ago #166422

For the PDF invoice, it's a different code that you need to use:
<?php echo $order->customer->user_email; ?>

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

  • Posts: 8
  • Thank you received: 2
7 years 4 months ago #272898

I am sorry to ask, but i have no php knowledge. Can you point exactly how/where this code is inserted?

I believe this is the display > view section of the billing/shipping address where I would like the email address to come after:

current output: Mr. Customer
123 Main St.
92081 Vista, CA
United States of America
Telephone: 619.345.3422
Add email Here xxxxxxxxxx

 <table width="100%">
          <tr>
            <?php if($this->invoice_type=='full' && !empty($this->element->billing_address)){?>
            <td>
              <fieldset class="adminform" id="htmlfieldset_billing">
              <legend style="background-color: #FFFFFF;"><?php echo JText::_('HIKASHOP_BILLING_ADDRESS'); ?></legend>
                <?php
                  $class = hikashop_get('class.address');
                  echo $class->displayAddress($this->element->fields,$this->element->billing_address,'order');
                ?>
              </fieldset>
            </td>
            <?php }?>
            <td>
            <?php
              if(!empty($this->element->order_shipping_id) && !empty($this->element->shipping_address)){
                ?>
                <fieldset class="adminform" id="htmlfieldset_shipping">
                  <legend style="background-color: #FFFFFF;"><?php echo JText::_('HIKASHOP_SHIPPING_ADDRESS'); ?></legend>
                  <?php
                    if(empty($this->element->override_shipping_address)) {
                      $class = hikashop_get('class.address');
                      echo $class->displayAddress($this->element->fields,$this->element->shipping_address,'order');
                    } else {
                      echo $this->element->override_shipping_address;
                    }
                  ?>
                </fieldset>
                <?php
              }
            ?>
            </td>
          </tr>
        </table>

Last edit: 7 years 4 months ago by Jerome. Reason: [code] tag is nice !

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
7 years 4 months ago #272948

Hi,

You can add your code just before the tag </fieldset> in that piece of code.
Note however that it's not :
<?php echo $this->order->customer->user_email; ?>
but:
<?php echo $this->element->customer->user_email; ?>
that you should now use.
Also note that even if you make a mistake in a view file, you can click on the bin icon on the listing for that view file to revert to the default code. So you can do modifications by trial and error in the view files for small modifications like that.

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

  • Posts: 206
  • Thank you received: 10
  • Hikashop Multisite
6 years 11 months ago #284798

Hi Nicolas,

After updating Hikashop to 3.2.2 and the new attach invoice plugin this line stops working.
i tried to add $this->order or $this->element befor </fieldset> but both result in empty.

Can you have a look at it? Thanks!

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

  • Posts: 206
  • Thank you received: 10
  • Hikashop Multisite
6 years 11 months ago #284802

Found it allready.
This will work for me:

<?php echo $order->customer->user_email; ?>

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

Time to create page: 0.139 seconds
Powered by Kunena Forum