Last active
June 9, 2020 13:52
-
-
Save enamhasan/9002a0419272376d2cd35f453afe8b7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
====Add this block in theme.liquid before closing head </head> ===== | |
{% comment %} ## AGE VERIFICATION -- if user is tagged 'is18', don't load age verification JS. If they aren't, or aren't logged in, load it. {% endcomment %} | |
{% if customer.tags contains 'is18' %} | |
{% else %} | |
{{ 'age-verification.js' | asset_url | script_tag }} | |
{% endif %} | |
======================================= | |
function verifyAge(){ | |
var params = $('#verify-age-form').serialize(); | |
$.ajax({ | |
url: "https://jsavinvoices.com/ve/age-verification.php", | |
method: "GET", | |
data: params, | |
}).done(function(xml) { | |
//console.log(xml); | |
var verify = $(xml).find('WorkflowOutcome').text(); | |
var name = $(xml).find('FirstName').first().text() + ' ' + $(xml).find('LastName').first().text(); | |
var address = $(xml).find('Street').first().text() + ', ' + $(xml).find('City').first().text() + ', ' + $(xml).find('State').first().text() + ', ' + $(xml).find('ZipCode').first().text(); | |
//Adds name and address to pass/fail message from retrieved xml | |
$('.name').html(name); | |
$('.address').html(address); | |
//Removes verify button, hides the form, and shows pass/fail information | |
if(verify == 'Pass'){ | |
$('#checkout').attr('name', 'checkout'); | |
$('#verify').remove(); | |
$('#cartAgeVerification').hide(); | |
$('#cartAgeVerificationPass').show(); | |
}else if(verify == 'Fail'){ | |
$('#verify').remove(); | |
$('#cartAgeVerification').hide(); | |
$('#cartAgeVerificationFail').show(); | |
}else if(verify == 'Needs Further Review'){ | |
$('#cartAgeVerificationNeedFurtherReview').show(); | |
$('#cartAgeVerificationNeedFurtherReview').animate({backgroundColor:"#FFC3C3"},250); | |
$('#cartAgeVerificationNeedFurtherReview').animate({backgroundColor:"#fff"},250); | |
}else{ | |
$('#verify').remove(); | |
$('#cartAgeVerification').hide(); | |
$('#cartAgeVerificationDown').show(); | |
$('#cartAgeVerificationDown').animate({backgroundColor:"#FFC3C3"},250); | |
$('#cartAgeVerificationDown').animate({backgroundColor:"#fff"},250); | |
} | |
}).fail(function() { | |
$('#verify').remove(); | |
$('#cartAgeVerification').hide(); | |
$('#cartAgeVerificationDown').show(); | |
$('#cartAgeVerificationDown').animate({backgroundColor:"#FFC3C3"},250); | |
$('#cartAgeVerificationDown').animate({backgroundColor:"#fff"},250); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment