Jump to content

Get phone from customer first address


Recommended Posts

I want to send parameters from customer (name,e-mail and phone) and the product name to contact form with tpl an js. But the problem is how to get the phone value, i know only you can get phone like that in tpl {$customer.addresses [Address ID] .phone}. I know you can have multiple addresses, but i want to get first one, and of course to check if it exist. All this data i want to add is in product.tpl file. Any solution how to get first Address ID from customer?

 

Quote

 

<!--Contact Form Parameters-->

{if $customer.is_logged}

<p>Customer FirstName : {$customer.firstname}</p>

<p>Customer Name: {$customer.lastname}</p>

<p>Customer Email: {$[customer.email](https://customer.email)}</p>

<p>Customer ID: {$[customer.id](https://customer.id)}</p>

<p>Phone: ***~~{$customer.addresses\[7\].phone}~~***</p>

{/if}

{if $product.name}<p>Product: {$product.name}</p>{/if}

<!--/Contact Form Parameters--> 

 

  

 

 

 

Edited by Striker Production (see edit history)
Link to comment
Share on other sites

Well I found by myself a solution to get the phone number from first address, is not the best, but is working...

{foreach $customer.addresses as $address}
       {if $address@iteration == 1}
         <p>Phone: {$customer.addresses[$address.id].phone}</p>
     {/if}
{/foreach}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...