Customization of address data in My account, Email and Receipt

  • Posts: 91
  • Thank you received: 5
3 years 4 months ago #327395

-- HikaShop version -- : 4.4.0
-- Joomla version -- : 3.9.23
-- PHP version -- : 7.3.24
-- Browser(s) name and version -- : Chrome 87

Hello,

I edited address template in
/templates/my_template/html/com_hikashop/address/address_template.php
and I see it applies to frontend, like My Account page.
I also edited it in
/administrator/templates/isis/html/com_hikashop/order/address_template.php
and it applies to Email sent to customer or admin.

How can I make a difference for Payment address and Shipment address?
For example my Payment address would be

{address_company}
{address_firstname} {address_lastname}
{address_street}
{address_post_code} {address_city}
{tax_number}
and Shipment address
{address_company}
{address_firstname} {address_lastname}
{address_street}
{address_post_code} {address_city}
{address_telephone}
So the last line changes.

Thanks

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
3 years 4 months ago #327397

Hi,

Well, you can restrict the custom address fields to only shipping and only billing via the Display>Custom fields menu.
So if you do that, then you can just do like this:

{address_company}
{address_firstname} {address_lastname}
{address_street}
{address_post_code} {address_city}
{tax_number}{address_telephone}
That way, since either of the field will be empty on the last line, you'll only get the remaining field displayed.
Now if you want to keep the fields in each type of address but only change the display, it will require some PHP coding.
{address_company}
{address_firstname} {address_lastname}
{address_street}
{address_post_code} {address_city}
<?php if($this->address->address_type=='billing')){ echo '{tax_number}'; }else{ echo '{address_telephone}'; } ?>

The following user(s) said Thank You: bolando

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

  • Posts: 2143
  • Thank you received: 747
3 years 4 months ago #327403

Hi,

Typo: one closing bracket too many.

<?php if($this->address->address_type=='billing')){ echo '{tax_number}'; }else{ echo '{address_telephone}'; } ?>
must instead be
<?php if($this->address->address_type=='billing'){ echo '{tax_number}'; }else{ echo '{address_telephone}'; } ?>


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
The following user(s) said Thank You: nicolas, bolando

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

  • Posts: 91
  • Thank you received: 5
3 years 4 months ago #327458

Hello,

Thanks, it helped me a lot.

Now I want to customize addresses in My account user panel.
1) In short address (one-line) I would like to have different fields for shipment and payment address. Tax number is important for payment, but not fir shipment. Is it possible?
2) How can I add phone to be visible in the Shipment long address (multi-line)? In my Hika settings I set phone only as a shipment field.
3) When I edit shipment address, I can't save it because it tells me I should fill in Phone, but the field is not visible there (see attachment). And tax number should not be displayed here (in Hika settings it's only for payment address).

Please help.

Attachments:

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
3 years 4 months ago #327468

Hi,

1. The mini format doesn't support PHP code. So you can't have different tags for different types of address in it.
I would recommend just not adding the tags for these fields. The goal of this address format is to have a small preview of the address for the customer when he chooses an address so you don't necessarily need all the information of the address in it.

2. The code I provided and lousyfool corrected will only display the address telephone for the shipping address. So this should already answer your question.

3. Could you provide a screenshot of the settings of both of these custom fields please ?

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

  • Posts: 91
  • Thank you received: 5
3 years 4 months ago #327495

Hello,

Thanks for your answer.

1) OK, I will tell it to the shop owner.
2) The code you provided works fine for HTML order summary in the front end for the customer
(URL: order/show/cid-18/cancel_url-aHR0cHM6Ly9zdGFsc2hvcC5wbC9tb2plLWtvbnRv), but not in the multi-line version address ready to be edited (URL: address)
My current code is

<?php
 defined('_JEXEC') or die('Restricted access');
?>
{address_company}
{address_street}
{address_post_code} {address_city}
<?php if($this->address->address_type=='billing'):?><?php if(!empty($this->address->nip)) echo JText::sprintf('NIP_NUMER','{nip}');?><?php else:?><?php if(!empty($this->address->address_telephone)) echo JText::sprintf('TELEPHONE_IN_ADDRESS','{address_telephone}');?><?php endif;?>
Somehow the if clauses not work (return always false).

3) I attach the settings.

Attachments:

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
3 years 4 months ago #327514

Hi,

2.
Change the code:

$params = null;
to:
$params = new HikaParameter('');
				$params->set('address', $address);
in the file administrator/components/com_hikashop/classes/address.php and it should fix that problem.

3.
Change the line:
$update_url = 'address&task=edit&cid='.(int)@$this->address->address_id;
to:
$update_url = 'address&task=edit&cid='.(int)@$this->address->address_id.'&address_type='.$this->address->address_type;
in the file components/com_hikashop/views/address/tmpl/show.php and it will fix the problem.

Please report back on this so that we can confirm the patches and add them for the next version.

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

  • Posts: 91
  • Thank you received: 5
3 years 4 months ago #327529

Hello,

Thanks for great support.
I applied the changes

2) Tax field already appears in the Payment address, but Telephone is not visible in Shipment address, and empty NIP (tax field) is there. I attach a screenshot.
3) It helped, thanks once again.

Attachments:

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

  • Posts: 4502
  • Thank you received: 610
  • MODERATOR
3 years 4 months ago #327533

Hello,

Sorry if I don't understand you well, but after processing some tests on your website, and was able to use your telephone field in your shipping address, see my screenshot :



If there a misunderstood can you describe more the recurrent issue in your Shipping address (from checkout)
Regards

Last edit: 3 years 4 months ago by Philip.

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

  • Posts: 91
  • Thank you received: 5
3 years 4 months ago #327568

Hello Phillip,

Thanks, this issue has been already resolved.
Now I would like to have the phone visible before editing the shipment address. I attach a screenshot.

Attachments:

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

  • Posts: 4502
  • Thank you received: 610
  • MODERATOR
3 years 3 months ago #327573

Hello,

I read the whole thread and so far, hard to tell what's didn't work after all this customization.
Provide via our Contact us form some backend references (with full access), and don't forget to add an Url link to this topic in your message.

Awaiting your references to progress.
Regards

Last edit: 3 years 4 months ago by Philip.

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

  • Posts: 91
  • Thank you received: 5
3 years 3 months ago #327662

Hello,
Did you receive my backend references? I sent them on Friday evening via www.hikashop.com/support/contact-us.html

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
3 years 3 months ago #327671

Hi,

Well, the problem is with your custom code in the "address format" setting.
You had a check $this->address->address_type=='shipment' in there but there is no such address_type in HikaShop.
I've fixed up your code and simplified it:

<?php if($this->address->address_type=='billing' && !empty($this->address->nip)) echo JText::sprintf('NIP_NUMER','{nip}');?>
<?php if($this->address->address_type=='shipping' && !empty($this->address->address_telephone)) echo JText::sprintf('TELEPHONE_IN_ADDRESS','{address_telephone}');?>
It now works fine as far as I can see:
monosnap.com/file/pwm9mRooR74UiCx2VyhAVzskiYdeYl

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

  • Posts: 91
  • Thank you received: 5
3 years 3 months ago #327688

Thank you for your help. I am afraid in this view: moje-konto/address it's still the same. I attach a screenshot.
How can I fix it?

Just to know: are such thing like address type checks described somewhere in the documentation or I should ask here in the forum about the syntax?

Attachments:

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
3 years 3 months ago #327714

Hi,

I had a look at it and there was a problem with the caching of the address template which prevented the display of different address formats on that view.
I've added a patch to fix that on your website and we'll also add it on our end for the next version of HikaShop.

There is no documentation for advanced address format customization like what you're trying to do.
For simple customization, the documentation of the "address format" setting on the configuration documentation page is enough:
www.hikashop.com/support/documentation/5...ml#checkout_shipping

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

  • Posts: 91
  • Thank you received: 5
3 years 3 months ago #327722

Thank you, now it works!
OK, so I will always ask here on a forum when starting some advanced customization.

Happy Christmas Time!

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

Time to create page: 0.101 seconds
Powered by Kunena Forum