Pregunta

It seems this is where I can parse information to the notes section of an order:

{{ cart.note }}

This was my code to try and add the discount code to the cart note:

{% for discount in discounts %}
discount.code = {{ cart.note }}
{% endfor %}

Can anyone please tell me where I went wrong?

¿Fue útil?

Solución

There are a couple of problems with what you're trying to do here.

  1. The discounts variable is part of an order, and does not exist yet on the Cart page (discounts are added by the customer during the checkout process).

  2. cart.note is created by having an input element with name="note" inside the form on the Cart page, and the value of that element becomes the order's note. See here for more info.

Also, from the Shopify wiki about cart.note:

Adds a note field to your checkout template... The general idea is that you simply define an input field named "note" in the form that submits to "/cart" in cart.liquid.

Where are you putting your code?

order.note may be editable via the API, but I haven't tried this so I'm not sure.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top