Add to Cart button on collection page- Prestige Theme

aartiduggal04
Tourist
4 0 1

Hi,

I would like to add 'Add to cart' button on my collection pages in the prestige theme. Can someone help?

0 Likes
newyorksockco
New Member
1 0 0

Hi, did you solve this? I have the same question.

 

0 Likes
aartiduggal04
Tourist
4 0 1

We added it via an app from the shopify app store

0 Likes
MercedesM
New Member
4 0 0

Hi, I have same problem. What is the name of the app you are using?

0 Likes
MercedesM
New Member
4 0 0

Hi, I have same problem. What is the name of the app you are using?

0 Likes
MercedesM
New Member
4 0 0

Thanks, I have installed the app and it's working fine. 

If anybody find another solution that I can put in code, please notify me. Thanks a lot!

 

0 Likes
Guleria
Shopify Partner
1445 297 410

Hello.

Add this code in product-item.liquid  under Snippets 

 

<button  type="submit" name="add" aria-label="Add to cart" class="ad_to_cart_coll Button Button--primary" id="ad_to_cart" aria-haspopup="dialog" data-add-to-cart="{{ product.variants.first.id }}" data-var_id="{{ product.variants.first.id }}">
          Add to cart</button>
Copy

 

Note: Make it conditional a/to your need.

Next in custom.js under Assets, add this code

 

$('.ad_to_cart_coll').click(function(){    
  var ID = $(this).attr("data-var_id");
  addItemToCart( ID, 1);    // paste your id product number
  $('.cart_dr').trigger( "click" );
});
function addItemToCart(variant_id, qty) {
  data = {
    "id": variant_id,
    "quantity": qty
  }
  jQuery.ajax({
    type: 'POST',
    url: '/cart/add.js',
    data: data,
    dataType: 'json',
    success: function() { 
      document.documentElement.dispatchEvent(new CustomEvent('cart:refresh', {
        bubbles: true  //this code is for prestige theme, is to refresh the cart
      }));
    }   
    
  }); 
 
}
Copy

 

 
Thanks

Want to modify or custom changes on store hire me.
Email: guleriathakur43@gmail.com, Skype: navrocks1
If helpful then please Like and Accept Solution.
0 Likes
MercedesM
New Member
4 0 0

Hi, Thanks a lot for your code.

I think I have made something bad because I have show the button add to cart but when I push the button add to cart it don't work, the item don't go to the cart.

Can you help me?

 

0 Likes
Guleria
Shopify Partner
1445 297 410

I posted this code after implementing it on Prestige theme. And if it still doesn't work for you then I  suggest hire a developer to implement.
or may be there is JS conflict in you theme code that's why my code is not working, you can check console to confirm.

Want to modify or custom changes on store hire me.
Email: guleriathakur43@gmail.com, Skype: navrocks1
If helpful then please Like and Accept Solution.
0 Likes