Personalized checkout and custom promotions with Shopify Scripts
I'm trying to edit the code I found on https://community.shopify.com/c/shopify-design/site-access-add-age-verification-to-your-online-store...5 so that I can also check their state. I've got the state box entered, and it will pop up an alert, but I can't figure out how to make it so that only certain states are allowed in. We can only ship to certain states, so we want to make that known up front.
This is what I have so far for the function:
function stateCheck() {
var legal_state = {{ enter_state }}; // sets legal states
var state = parseInt(document.getElementById('bystate').value);
if ((bystate != legal_state)) {
{alert("this state is not legal. we can not sell to you.")}
} else {
var state = parseInt(document.getElementById('bystate').value);
if ((bystate = legal_state)) {
location.reload();
}
}
}
Above that I reference the values of the states that are legal. I only entered for for testing.
{% assign legal_state = 50 %}
<option value="50">WI</option>
The option value is listed in a drop down in a select area.
Any suggestions?
Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024