How to add custom email validation in billing form - checkout modal

Hi, is there a way to add custom validations in the billing form? I want to validate that only unique email address is allowed. Is there an event I can use to attach a condition before continuing to the payment section? Can I override the Continue to Payment button? I’m currently using the latest SnipCart version (v3). Any suggestions are greatly appreciated.

Hey @hcars2096,

I want to validate that only unique email address is allowed.

We have the Custom Validation with the billing-address to validate the email address of the customer. But you’ll need to have the list of emails on your side. If you already have that, it should be pretty straightforward to add this validation. If you want to get the list from Snipcart, the only way I see right now would be with an undocumented private API. We can assist you if you want to go in this direction, but we can’t guarantee it doesn’t change since it’s undocumented. It usually doesn’t change often. We have a couple of customers that have been using it for a while, but we cannot provide any guarantee since it’s a private API.

Can I override the Continue to Payment button?

I find it a bit hard to see how you would override that. What would you like to do with this? Do you want to skip the Payment step or something similar?

I’m curious to understand your need to prevent an existing previous customer from buying from your website by validating for a unique email address, knowing that we might be able to help you more to achieve what you want.

Thanks.

It seems that the custom validation with event type page.validating doesn’t work in SnipCart v3. We do have a list of emails and our app needs to check if the customer is a first-time purchaser or an existing one.

Below is a code snippet I use to check for the events in billing address form.

Snipcart.events.on('page.validating', function (ev, data) {
       if (ev.type == 'billing-address') {
             console.log('add custom validation');
        }
    });

You’re absolutely right,

I’m sorry about the version confusion. Sadly it’s not supported in v3 as you mentionned and can see here.

We’ll reach out to you when we plan to include this in a further release

Cheers!