Have your say in Community Polls: What was/is your greatest motivation to start your own business?

How to render dynamically the customers phone number?

How to render dynamically the customers phone number?

mpatsia
Shopify Partner
87 0 8

Greetings, i tweaked the signup form so the user must add the phone number but in notived that the phone number is not rendered in the account page.

 

Screenshot from 2023-10-20 11-51-59.png

 

Screenshot from 2023-10-20 11-51-23.png

 

This is the HTML in the form page

```

<input type="tel" name="customer[phone]" placeholder="Τηλέφωνο" class="form-control">

```

 

This is the HTML in the account page

```

<div class="flex border-b border-color-border py-5">
<div class="w-1/3">Τηλέφωνο</div>
<div class="w-2/3">
<span class="text-color-secondary">{{ customer.phone }}</span>
</div>
</div>

```

 

Does anyone know how can i render it correctly?

 

Thanks in advance

Replies 4 (4)

maxdanko
Shopify Partner
29 3 7

This phone number is only populated if the customer checks out using a phone number during checkout, opts in to SMS notifications, or if the merchant has manually entered it.

You can add a condition to your account page: 

                         {%- if customer.phone != blank -%}
                            <span>{{ customer.phone }}</span>
                        {%- else -%}
                            <span>Phone number is not filled in.</span>
                        {%- endif -%}
mpatsia
Shopify Partner
87 0 8

Hello, and thanks for reply. I want to sho the phone number added by the user in the registration form, is the 4th field in the above form.

maxdanko
Shopify Partner
29 3 7

To allow the user to enter the phone number on the registration page you need to change the field for entering the phone number
<input type="tel" name="customer[note][Phone]" placeholder="Τηλέφωνο" class="form-control">

Once registered, the phone number will be recorded in the user's "notes" in the admin panel.
However, in order to display this phone number on the account page it must be filled in anyway, either by the administrator or by the user when the user is on the checkout page.

 

maxdanko_0-1697804648860.png

 

Brett_Helium
Shopify Partner
284 53 128

Hey @mpatsia!

Unfortunately I don't believe it is currently possible to collect a phone number directly using the default registration form, unless you only store it in the notes section as someone else mentioned.

Another option would be to use an app like Helium Customer Fields to create a custom registration form which would allow you to collect things like phone number, address, or other custom fields, and have them saved directly to the customer's account. 

Brett | Helium
- Customer Fields ✪✪✪✪✪ (360+ reviews)
- Meteor Mega Menu ✪✪✪✪✪ (290+ reviews)
- Strike Automatic Discounts NEW!