Add To Cart Button Not Disabling even if variant is not displayed

Hi!

Can anyone help me? I was able to show/hide my variants based on this logic

  1. Variant contains “VAT Exempt”

  2. Customer has tag “seniorpwd”

Basically, the VAT Exempt variant will only be displayed if the customer with tag “seniorpwd” logs in and attempts to purchase. Likewise, the Variant “VAT Exempt” should be hidden if the customer does not have a tag “seniorpwd”. This part works.

However, for some reason, the Add To Cart button is still enabled even if the “VAT Exempt” variant is not shown. It seems that the “Add To Cart” button is enabled based on the variant that contains inventory. Which, in this case is the VAT Exempt variant. Is there a way to control the setting of default variant? I would like the Add To Cart button be enabled/disabled correctly with my conditions above.

I am using Dawn theme. Thank you!

@kathychan Hope you are doing well. Could you please share your store URL?

Hi! I am fairly new with Shopify development. Is this the one you’re looking for?
https://goct6x8h5u6pzg4c-72196260126.shopifypreview.com

This is a screenshot of the problem I was referring to. As you can see, the variant is not visible, yet the Add To Cart button is enabled. It ends up adding the wrong variant.

Do you still need help with this?

Yes

Hi!

I was able to find the solution for this! It took a while, but the update I did was on the buy-buttons.liquid and included the logic to control the settings of Add To Cart button. Thanks!