How to get value from customer phone field in shopify?

by dalton_moen , in category: PHP CMS , a month ago

How to get value from customer phone field in shopify?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dana , a month ago

@dalton_moen 

To get the value from the customer phone field in Shopify, you can use the following code:

  1. Retrieve the customer information from the customer object:
1
2
3
{% if customer %}
  Customer Phone: {{ customer.phone }}
{% endif %}


  1. If you want to access the customer's phone number in the checkout process, you can use the following code:
1
2
3
{% if checkout %}
  Customer Phone: {{ checkout.billing_address.phone }}
{% endif %}


  1. If you want to access the customer's phone number in the order confirmation email, you can use the following code:
1
2
3
{% for line_item in order.line_items %}
  Customer Phone: {{ order.billing_address.phone }}
{% endfor %}


These Liquid code examples will allow you to retrieve the customer's phone number from the customer object, checkout object, and order object in Shopify.