<p>What I gathered from the documentation, you could try this:</p>

<pre><code>{% set customer = craft.commerce.getCustomer() %}
</code></pre>

<p>then</p>

<pre><code>{{ customer.address.businessName }}
</code></pre>

<p>or it might be </p>

<pre><code>{{ customer.addresses.businessName }}
</code></pre>

<p><a href="https://craftcommerce.com/docs/customer-model" rel="nofollow noreferrer">https://craftcommerce.com/docs/customer-model</a></p>

CC BY-SA 3.0
2017-04-13T17:41:03.550Z
2017-04-13T17:41:03.550Z
Brad
<p>When a user registers on my site, I am asking for their first, last, email and address.</p>

<p>I would like to be able to pass the data I already have along to commerce. So when I get to the <code>/address</code> screen, as much of that form is already pre-populated.</p>

<p>I see this:</p>

<pre><code>{% set modelName = modelName is defined ? modelName : 'address' %}
{% set model = address is defined ? address : null %}
</code></pre>

<p>So I (think) the ideal solution is to set the model to the user model. I will never allow guest checkout on this site, yet I want to keep as much flexibility as possible (not delete a bunch of stuff). So I gave this a shot:</p>

<pre><code>{% if currentUser %}
    {% set modelName = modelName is defined ? modelName : 'user' %}
    {% set model = user is defined ? user : null %}
{% else %}
    {% set modelName = modelName is defined ? modelName : 'address' %}
    {% set model = address is defined ? address : null %}
{% endif %}
</code></pre>

<p>And I get this error: </p>

<pre><code>Craft\UserModel and its behaviors do not have a method or closure named "businessName".
</code></pre>

<p>Which makes perfect sense - that's not in the user model.</p>

<p>I could go into the form filed and just set the values like this:</p>

<pre><code>&lt;input type="text" id="{{ modelName }}-firstName" class="form-control"
                   name="{{ modelName }}[firstName]"
                   value="{{ currentUser.firstName }}"&gt;
</code></pre>

<p>But is that going to lead to disaster? Thank you for any suggestions!</p>

<plugin-development><plugin-craftcommerce>
How can I pre-populate my billing/shipping information within Commerce?
# How can I pre-populate my billing/shipping information within Commerce?

(Asked by: username_0 on 2017-04-13)

When a user registers on my site, I am asking for their first, last, email and address.
I would like to be able to pass the data I already have along to commerce. So when I get to the /address screen, as much of that form is already pre-populated.
I see this:
{% set modelName = modelName is defined ? modelName : 'address' %}
{% set model = address is defined ? address : null %}

So I (think) the ideal solution is to set the model to the user model. I will never allow guest checkout on this site, yet I want to keep as much flexibility as possible (not delete a bunch of stuff). So I gave this a shot:
{% if currentUser %}
    {% set modelName = modelName is defined ? modelName : 'user' %}
    {% set model = user is defined ? user : null %}
{% else %}
    {% set modelName = modelName is defined ? modelName : 'address' %}
    {% set model = address is defined ? address : null %}
{% endif %}

And I get this error: 
Craft\UserModel and its behaviors do not have a method or closure named "businessName".

Which makes perfect sense - that's not in the user model.
I could go into the form filed and just set the values like this:


But is that going to lead to disaster? Thank you for any suggestions!

**Tags:** plugin-development, plugin-craftcommerce


---

## 1 answers

### Answer by username_1 on 2017-04-13. Score: 1 | Accepted answer

What I gathered from the documentation, you could try this:
{% set customer = craft.commerce.getCustomer() %}

then
{{ customer.address.businessName }}

or it might be 
{{ customer.addresses.businessName }}

https://craftcommerce.com/docs/customer-model


---

