Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Dawn Theme 4.0 Add to cart and QTY selector on Collections. AJAX Add to cart on collection page

Dawn Theme 4.0 Add to cart and QTY selector on Collections. AJAX Add to cart on collection page

PantsMcGhee
Tourist
6 1 1

Hi all, I have tried a few solutions from this community to place add to cart buttons and qty selector to collection pages, plus tried deferring the javascript on collection pages so that add an item to the cart updates on the collection page and does not take you directly to the cart page.

 

None of the code snippets have worked. For example, everyone says to edit; product-card.liquid, but this file does not seem to exist anymore (or has been renamed) to; card-product.liquid and the overall code looks different.

 

I tried this code in; snippets > card-product.liquid

<!-- Add to cart on collection page -->
            <form method="post" action="/cart/add">
<input type="hidden" name="id" value="{{ product_card_product.variants.first.id }}" />
<input type="hidden" type="number" id="quantity" name="quantity" value="1"/>
<input type="submit" value="Add to cart" class="button" style="margin-top: 17px" />
</form>
            <!-- END -->

 and this code in the <head> of theme.liquid;

<!-- Disable add to cart going to cart page on collections -->
    {% if template == 'collection' %}
    <script src="{{ 'product-form.js' | asset_url }}" defer="defer"></script>
    {% endif %}
    <!-- END -->

Does anyone have a solution for Dawn version 4.0.0?

Thank you.

Reply 1 (1)

ahirwp
Shopify Partner
12 2 0

Hi


There is already an options in theme settings to show add to cart button on Collection page:
inside card-product.liquid file you can see code between this conditions.

{%- if show_quick_add -%}
// Add to cart code here
{% - endif -%}

Thanks
Ahir