Create a add to cart button in "feature collection" on Dawn theme

Solved

Create a add to cart button in "feature collection" on Dawn theme

ThomKnepper
Shopify Partner
188 30 69

Currently I am working on setting up a store with the Dawn theme but I would like to put a "add to cart" button next or below the pricing in a featured collection. This way people should be able to add to the cart without needing to go to the product page first. However, when I load in the following html+liquid below the pricing tag I get an error.

 

<product-form class="product-form">
	{%- form 'product', product, data-productid: product.id, id: product_form_id, class: 'form', novalidate: 'novalidate', data-type: 'add-to-cart-form' -%}
    	<input type="hidden" name="id" data-productid="{{ product.id }}" value="{{ product.selected_or_first_available_variant.id }}">
        	<div class="product-form__buttons">
            	<button
                type="submit"
                name="add"
                class="product-form__submit button button--full-width {% if block.settings.show_dynamic_checkout and product.selling_plan_groups == empty %}button--secondary{% else %}button--primary{% endif %}"
                {% if product.selected_or_first_available_variant.available == false %}disabled{% endif %}
                >
                {%- if product.selected_or_first_available_variant.available -%}
                	{{ 'products.product.add_to_cart' | t }}
                {%- else -%}
                    {{ 'products.product.sold_out' | t }}
                {%- endif -%}
                </button>
                {%- if block.settings.show_dynamic_checkout -%}
                    {{ form | payment_button }}
                {%- endif -%}
            </div>
       {%- endform -%}
</product-form>

 

 

I get the following error:

Liquid error (add-to-cart line 2): product form must be given a product

I hope someone can help with this.

Best wishes,
Thom Knepper - Athom.Agency
- Was my reply helpful? Please Like to let me know!
- Was your question answered? Awesome! Please Mark it as an Accepted Solution
Accepted Solution (1)

Guleria
Shopify Partner
3393 675 955

This is an accepted solution.

Hello @ThomKnepper ,

I already posted a answer here https://community.shopify.com/c/shopify-design/dawn-thene-2-0-add-to-cart-on-collection-page-with-aj...

Thanks

- If helpful then please Like and Accept Solution.
- Drop an email   if you are looking for quick fix or any customization ( paid services )
- Email: guleriathakur43@gmail.com
- Try GEMPAGES a great page builder

View solution in original post

Replies 3 (3)

Guleria
Shopify Partner
3393 675 955

This is an accepted solution.

Hello @ThomKnepper ,

I already posted a answer here https://community.shopify.com/c/shopify-design/dawn-thene-2-0-add-to-cart-on-collection-page-with-aj...

Thanks

- If helpful then please Like and Accept Solution.
- Drop an email   if you are looking for quick fix or any customization ( paid services )
- Email: guleriathakur43@gmail.com
- Try GEMPAGES a great page builder
ThomKnepper
Shopify Partner
188 30 69

Brilliant! Thank you so much!

Best wishes,
Thom Knepper - Athom.Agency
- Was my reply helpful? Please Like to let me know!
- Was your question answered? Awesome! Please Mark it as an Accepted Solution
akarshan2602
Visitor
2 0 0

hey, it got added but it's not working, i mean it's not adding the items to the cart