Add to Cart button doesn't work on products with variants (sometimes)

Solved

Add to Cart button doesn't work on products with variants (sometimes)

GrayFox
Visitor
3 0 0

I just noticed the "Add to Cart" button becomes disabled as soon as I pick a variant of one of my products, like a hat size, making it impossible to add those items to my cart. However, I can add an item if I don't pick a variant or if there is only one variant available or if I refresh the page after selecting a variant.

 

My website (and product page to test issue): https://grayfoxww.com/products/flexfit-branded-hat-white

 

Thank you in advance!

Accepted Solution (1)
LitExtension
Shopify Partner
4860 1002 1160

This is an accepted solution.

Hi @GrayFox,

Please go to sections > main-product.liquid file, find 'pickup-availability'. Please check the declaration of pickup-availability.js file, is it like the following screenshot?

Screenshot.png

If the declaration is correct, please go to Assets and create the file pickup-availability.js

Screenshot.png

After that, copy the following code and paste it in: https://github.com/Shopify/dawn/blob/main/assets/pickup-availability.js

Hope it helps!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify

View solution in original post

Replies 8 (8)

PaulNewton
Shopify Partner
7151 633 1488

The sites theme has a console error:

global.js?v=138967679220690932761645924793:810 Uncaught TypeError: pickUpAvailability.fetchAvailability is not a function
    at VariantSelects.updatePickupAvailability (global.js?v=138967679220690932761645924793:810:26)
    at VariantSelects.onVariantChange (global.js?v=138967679220690932761645924793:746:10)

 

Issues like this can often stem from modifications made to the related product template, such as invalid html, or important javascript not being output.

Contact [email protected] for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


GrayFox
Visitor
3 0 0

Thank you for finding the issue. How would I go about fixing it? I'm really not well-versed in coding to go at it by myself. I had a hard enough time describing the issue. Haha

GrayFox
Visitor
3 0 0

GrayFox_1-1652613471190.png

I found the code that needs to be altered, I just don't know how to alter it.

LitExtension
Shopify Partner
4860 1002 1160

This is an accepted solution.

Hi @GrayFox,

Please go to sections > main-product.liquid file, find 'pickup-availability'. Please check the declaration of pickup-availability.js file, is it like the following screenshot?

Screenshot.png

If the declaration is correct, please go to Assets and create the file pickup-availability.js

Screenshot.png

After that, copy the following code and paste it in: https://github.com/Shopify/dawn/blob/main/assets/pickup-availability.js

Hope it helps!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Creon
Tourist
6 0 2

Hi, I tried this and I already had the pickup-availability.js function. It did not work. I still cannot add to cart.

KanishkT
Shopify Partner
32 0 11

Hey @GrayFox,

If you want to continuously monitor and test your store for issues like "add-to-cart not working" and "checkout not working", you can use this free app called Store Watchers - Automated Testing & Monitoring Solution for Shopify.

This app will help you monitor whether your functionalities are operational or not. If any issue occurs and your customer is facing it then you can take immediate steps to fix these issues and offer your customer a great purchasing experience.

Hope this helps 🙂

Marketing Manager at Wholesale Helper
App Store - https://apps.shopify.com/partners/goldj
Website - https://wholesalehelper.io/

mayleemouse
Visitor
1 0 0

I was having the same issue, turns out that it happens when my variants have the "/" symbol in their names, I switched from "2 - Sky Blue / Matte" to "2 - Sky Blue Matte" and now the Add to cart button works again on my variants.
I hope this helped!

earreplaceable
Visitor
2 0 0

Was this symbol in the code?

How can I see if that is my issue?