How do I add the field "Username" to Invoice?

  • Posts: 22
  • Thank you received: 2
10 years 2 months ago #166550

-- HikaShop version -- : 2.3.2
-- Joomla version -- : 2.5.24
-- PHP version -- : 5.4
-- Browser(s) name and version -- : chrome

I would like to add the field "username" to the invoice. I have found the Display->Views->Invoice and can edit the code. I would like to add the following but obviously I have the syntax wrong as it is not displaying the username:

<?php echo JText::_('QJA Member').': '.@$this->username;?>

Can anyone help with some advice on the syntax for the username field please.

Thanks,
Keith

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
10 years 2 months ago #166565

Hi,

Try like that:
<?php echo JText::_('QJA Member').': '.@$this->element->username;?>

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

  • Posts: 22
  • Thank you received: 2
10 years 2 months ago #166675

Thank you for you reply. I updated my syntax to match your suggestion - unfortunately it displays the text "QJA Member" fine but the field content is still blank.

The syntax reads:

              <fieldset class="adminform" id="htmlfieldset_billing">
              <legend style="background-color: #FFFFFF;"><?php echo JText::_('HIKASHOP_BILLING_ADDRESS'); ?></legend>

<?php echo JText::_('QJA Member').': '.@$this->element->username;?><br/>

                <?php
                  $this->setLayout('address_template');
                  $html = $this->loadTemplate();
                  foreach($this->element->fields as $field){
                    $fieldname = $field->field_namekey;
                    $html=str_replace('{'.$fieldname.'}',$this->fieldsClass->show($field,$this->element->billing_address->$fieldname),$html);
                  }
                  echo str_replace("\n","<br/>\n",trim(str_replace("\n\n","\n",preg_replace('#{(?:(?!}).)*}#i','',$html)),"\n"));
                ?>
              </fieldset>
Third line down is the line I have added.

Any ideas?

Regards,
Keith

Last edit: 10 years 2 months ago by Jerome. Reason: [code] is nice !!

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

  • Posts: 26146
  • Thank you received: 4026
  • MODERATOR
10 years 2 months ago #166698

Hi,

I will make the supposition that you are edting the view "backend | order | invoice" (it is always better the provide the full localisation of the view, because if there are several views with the same name ; they don't have the same path !)

The full order is loaded under $this->element
The user is loaded by the full order, it will be under $this->element->customer
So, the username : $this->element->customer->username

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: qjawebadmin

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

  • Posts: 22
  • Thank you received: 2
10 years 2 months ago #166838

Perfect - worked a charm. Thank you very much.
Keith

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

Time to create page: 0.059 seconds
Powered by Kunena Forum