{"title":"Create an add-to-cart form using Liquid","slug":"liquid-how-to-form-helper","url":"https://support.storeconnect.com/articles/liquid-how-to-form-helper","url_markdown":"https://support.storeconnect.com/articles/liquid-how-to-form-helper.md","subtitle":null,"summary":"Build an add-to-cart form with the Liquid form helper. Examples cover simple product forms and variant selection with size and color options.","type":"Help_Documentation","video_url":"","keywords":"liquid, form helper, add-to-cart form, cart form, product variants, variant selection, liquid templating, all_products, checkout form, add to cart, product options, liquid code examples","last_modified":"2026-08-21T07:12:35+0000","body_markdown":"You can create an add to cart form using the Liquid `form` helper. To do this you first find the product you want to add the form for and then use the form helper to wrap your HTML code in a form.\n\nFor example:\n\n\n```\n{% assign product = all_products[\"aloe-foaming-cleanser-100ml\"] %}\n\n{% form \"add-to-cart\", product_id: product.id %}\n\n\n\n      Quantity\n\n\n\n\n\n{% endform %}\n```\n\n\nIf your product has variants in it, you could handle this by allowing the user to select a specific variant:\n\n\n```\n{% assign product = all_products[\"tennis-shoe\"] %}\n\n{% form \"add-to-cart\", product_id: product.id %}\n\n\n\n      Quantity\n\n\n\n\n      Size 37\n      Size 38\n      Size 39\n      Size 40\n\n\n\n      White\n      Multi\n\n\n\n\n\n{% endform %}\n```\n\n\nNote, if the combination of options is not available due to stock or other reasons, the user will be shown the product page with an error message to select an available option."}