If a customer clicks a certain button in my Shopify store, I’d like to be able to add information to my cart using Liquid (or whatever is needed). This information can be as simple as a string. The customer won’t see this information, but it will be used to modify the look of the cart page. I can happily parse it/handle it as a string, if that’s my only option, but so far I can’t get any information to be sent. I have tried modifying cart.note using a {% capture %}
block, but that never ended up modifying anything permanently. I also am not sure how to change line_item
properties, but that might do it as well.
2
Answers
You can add input fields with the name
properties[some-prop-name]
to your product form, which would include the required linking dataFor example, adding the following input to your product form would add a line-item property to your product as you add it:
If you want to dynamically update line-item properties to add/rearrange items in boxes post-hoc you can do so using AJAX requests targeting the
/cart/change.js
endpointHere’s an example of such a command, which you would run upon the user changing the appropriate input element:
Hopefully this helps you get your feature in!
You can store that data in the line item properties.
Get customization information for products with line item properties
Then you can access the line item properties from your liquid template.