Discussing APIs and development related to customers, discounts, and order management.
I am trying to add a new checkbox for Authority to Leave. Followed the steps in shopify website: https://help.shopify.com/en/themes/customization/cart/get-more-information-with-cart-attributes
The checkbox shows up in the page but when calling the orders API to retrieve the transaction, the note_attributes field is always empty.
I contacted shopify support and they said the code looks okay but they can't explain why it doesn't show up in note_attributes.
Used shopify UI generator already and tried checking the shopify forums to no avail.
I've updated cart-template.liquid and added below inside the <form> tags
<p class="cart-attribute__field"> <input type="hidden" name="attributes[Authority To Leave]" value="No"> <input type="checkbox" name="attributes[Authority To Leave]" value="Yes" checked> <label>Authority To Leave</label> </p>
I can't seem to figure out why it doesn't show up in the note_attributes field.
Why do you have two input with the same name - being attributes[Authority To Leave]? That's the first problem to look at.
The forum members would also need to see the code that this snippet sits within. It's possible this code isn't added correctly.
Hi Jason,
This is the generated code from shopify UI generator (https://ui-elements-generator.myshopify.com/pages/cart-attribute)
Code snippet:
<form action="/cart" method="post" novalidate class="cart">
<table class="shop_table cart">
..
<tfoot>
<tr>
<td colspan="6" style="padding: 0;padding-top: 15px;">
{% if section.settings.cart_notes_enable == false %}
<a href="collections/all-wines" class="button medium border">{{ 'cart.general.continue_shopping' | t }}</a>
<button class="button medium" style="float: right;" name="update">{{ 'cart.general.update' | t }}</button>
{% endif %}
</td>
</tr>
</tfoot>
</table>
{% if section.settings.cart_notes_enable %}
<div class="row">
<div class="grid__item col-lg-12 col-xs-12 cart-note">
<label for="CartSpecialInstructions" class="cart-note__label small--text-center">{{ 'cart.general.note' | t }}</label>
<label for="CartSpecialInstructions2" class="cart-note__label small--text-center">{{ 'cart.general.note2' | t }}</label>
<p class="cart-attribute__field">
<input type="hidden" name="attributes[Authority To Leave]" value="No">
<input type="checkbox" name="attributes[Authority To Leave]" value="Yes" checked>
<label>Authority To Leave</label>
</p>
<textarea rows="3" name="note" id="CartSpecialInstructions" class="cart-note__input">{{ cart.note }}</textarea>
<a href="collections/all-wines" class="button medium border" style="margin-right: 15px;">{{ 'cart.general.continue_shopping' | t }}</a>
<button class="button medium" style="margin-top: 15px;">{{ 'cart.general.update' | t }}</button>
</div>
</div>
{% endif %}
</form>