I have a problem, I made a switch case in my ajax.js file but even if the values fit a case, this is always the default case which is return,
someone has an idea why?
There my code :
app/code/Vendor/CustomerZipCode/view/frontend/web/js/ajax.js
define([
'jquery',
'underscore',
'mage/template',
'mage/url'
], function (
$,
_,
template,
url
) {
'use strict';
$(document).ready(function() {
var ajaxurl = url.build('customerzipcode/zipcode');
$('#zip_btn').val("not clicked");
$('#zip_btn').on('click', function () {
let Zip = $('#zip_txt').val();
$('#zip_btn').val("clicked");
$.ajax({
showLoader: true,
url: ajaxurl,
data: {zipcode : Zip},
type: "POST",
dataType: 'json'
}).done(function (data) {
$('#test').removeClass('hideme');
let displayzip ="You enter "+data['ZipCode']+" as zipcode <br/>";
let fullchoice="You can choice between delivery or store pickup (for order over 200$)";
let partialchoice="You can choice between delivery or store pickup, both for order over 200$";
let nochoice="You are eligible only for store pickup for order over 200$";
let html;
console.log(data['ZipCode']);
switch(data['ZipCode']){
case 11222 || '11222':
html=fullchoice
break;
case 11211 || '11211':
html=fullchoice
break;
case 11249 || '11249':
html=fullchoice
break;
default:
html=nochoice
}
$('#test p').html(displayzip+html);
});
});
});
});