<p>The text that is submitted using your <code>&lt;input&gt;</code> field will display as expected with <code>Your Reference: {{ cart.customerReference }}</code>. </p>

<p>However, I have a feeling that because the page is re-rendered with the inputs <code>value</code> as empty, when the <code>/updateCart</code> action is submitted again the blank value will override and erase the old value.</p>

<p>To solve this use the <code>customerReference</code> stored on the cart in the <code>value</code> attribute of your text <code>&lt;input&gt;</code>.</p>

<pre><code>&lt;input ... value="{{ cart.customerReference|length ?? cart.customerReference }}"&gt;
</code></pre>

CC BY-SA 3.0
2016-07-21T15:56:10.893Z
2016-07-21T15:56:10.893Z
Luke Pearce
<p>Building on top of the Commerce Example Templates. I've made an order field called 'Customer Reference'. I'm submitting data like this:</p>

<pre><code>&lt;form class="shopForm" method="POST"&gt;
&lt;input type="hidden" name="action" value="commerce/cart/updateCart"&gt;
&lt;div class="field"&gt;
    &lt;label for="fields[customerReference]"&gt;Your Reference: {{cart.customerReference}}&lt;/label&gt;
    &lt;input type="text" name="fields[customerReference]" value=""&gt;
&lt;/div&gt;
&lt;input class="btn btn-outline" type="submit" value="Update Reference"&gt;
</code></pre>

<p></p>

<p>This code seems to work ok. But after updating the cart the data doesn't seem to be saved, it doesn't show up in the Commerce back end. I'm also not able to be display the data later on in the ordering process, on the receipt for example.</p>

<p>I'm using this to display the data from the field:</p>

<pre><code>{{cart.customerReference}} or {{order.customerReference}}
</code></pre>

<p>Can somebody tell me, possibly with some examples, how to properly submit and retrieve the content for custom order fields?</p>

<p>This is related to: <a href="https://craftcms.stackexchange.com/questions/13104/how-can-i-update-custom-order-fields-in-the-frontend">How can I update custom order fields in the frontend</a></p>

<p>Working with: mamp</p>

CC BY-SA 3.0
2016-05-02T17:47:57.040Z
Have you added the custom field to your order field layout in `Commerce > Settings > Order Fields`? Can you see the field in an order edit screen?
Luke Holder
CC BY-SA 3.0
2016-05-03T06:35:00.080Z
Yes, I have and there I am able to save data to the field, no problem. (Maybe relevant: this site only allows guest customers).
oxford
<plugin-craftcommerce>
How do I make use of the order fields In Commerce?
# How do I make use of the order fields In Commerce?

(Asked by: username_0 on 2016-05-02)

Building on top of the Commerce Example Templates. I've made an order field called 'Customer Reference'. I'm submitting data like this:



    Your Reference: {{cart.customerReference}}
    




This code seems to work ok. But after updating the cart the data doesn't seem to be saved, it doesn't show up in the Commerce back end. I'm also not able to be display the data later on in the ordering process, on the receipt for example.
I'm using this to display the data from the field:
{{cart.customerReference}} or {{order.customerReference}}

Can somebody tell me, possibly with some examples, how to properly submit and retrieve the content for custom order fields?
This is related to: How can I update custom order fields in the frontend
Working with: mamp

**Tags:** plugin-craftcommerce

> **Comments:**
> **username_1**: Have you added the custom field to your order field layout in `Commerce > Settings > Order Fields`? Can you see the field in an order edit screen?  
> **username_0**: Yes, I have and there I am able to save data to the field, no problem. (Maybe relevant: this site only allows guest customers).  

---

## 1 answers

### Answer by username_2 on 2016-07-21. Score: 3

The text that is submitted using your  field will display as expected with Your Reference: {{ cart.customerReference }}. 
However, I have a feeling that because the page is re-rendered with the inputs value as empty, when the /updateCart action is submitted again the blank value will override and erase the old value.
To solve this use the customerReference stored on the cart in the value attribute of your text .


---

