Focusing on managing products, variants, and collections through the API.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
I've added a custom select field on my product page and removed the 'novalidate' attribute from `buy-buttons.liquid` file. Now the validation works when I click 'Add to cart', but it still doesn't work on 'Buy it now'. I've seen another question here about the same problem a few years back and the only answer was asking if they can just listen for a click event on the 'Buy it now' button. I've tried that but didn't work. Also, who says it will always be a 'click' event that triggers the button? Anyway... Is there a solution for this? It seems ridiculous to me to have the abbility to add custom fields and have them be required for adding to cart but not for buying now.
Hello @fpiskur ,
I never found a solution for it.
The alternative i use to solve it is, don't show the buy now button until custom fields have values.
Thanks
Where did you add the code for hiding the buy button? I can't remember exactly where I tried but it didn't work for me.
let buyBtn = document.querySelector('.shopify-payment-button__button');
buyBtn.style.display = 'none';
I even tried wrapping it inside a 'load' event listener.
You can just de-select it in the theme settings. When in customise mode- click on the button section and deselect 'dynamic' buttons.