FROM CACHE - en_header

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

Solved
ThomKnepper
New Member
3 0 1

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.

Accepted Solution (1)

Accepted Solutions
Guleria
Shopify Partner
2128 448 648

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

Want to modify or custom changes on store hire me.
Email: guleriathakur43@gmail.com, Skype: navrocks1
Try GEMPAGES a great app with drag and drop features.

View solution in original post

Replies 3 (3)
Guleria
Shopify Partner
2128 448 648

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

Want to modify or custom changes on store hire me.
Email: guleriathakur43@gmail.com, Skype: navrocks1
Try GEMPAGES a great app with drag and drop features.
ThomKnepper
New Member
3 0 1

Brilliant! Thank you so much!

akarshan2602
New Member
1 0 0

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