Cherry Cheesecake Foaming Hand Soap
Juicy Cherries, Graham Crackers, Butter, Vanilla Bean, and Sugar
Regular price
$10.00 USD
Regular price
Sale price
$10.00 USD
Unit price
/
per
Sale
Sold out
Couldn't load pickup availability
-
Vegan & Cruelty-free
-
100% Organic
-
Gluten-free
-
Free from Parabens, Sodium Laurel Sulfate (SLS/SLES), DEA/MEA/TEA, Triclosan, & Artificial Color
-
Hand made in small batches, in the USA
const variantSelects = (document.querySelector('variant-selects')) ? document.querySelector('variant-selects') : document.querySelector('variant-radios');
const pickerType = (variantSelects.querySelectorAll('fieldset').length > 0) ? 'radios' : 'selects';
const fieldsets = (pickerType == 'radios') ? Array.from(variantSelects.querySelectorAll('fieldset')) : Array.from(variantSelects.querySelectorAll('.product-form__input--dropdown'));
const productJson = JSON.parse(variantSelects.querySelector('[type="application/json"]').textContent);
let selectedOptions = [];
variantSelects.addEventListener('change', rebuildOptions);
this.rebuildOptions();
function validCombo(inputValue, optionLevel) {
for(let i = 0; i < productJson.length; i++) {
if(optionLevel == 1){
if (productJson[i].option1 == selectedOptions[0] && productJson[i].option2 == inputValue) { return true; }
} else {
if (productJson[i].option1 == selectedOptions[0] && productJson[i].option2 == selectedOptions[1] && productJson[i].option3 == inputValue) { return true; }
}
}
}
function rebuildOptions() {
selectedOptions = fieldsets.map((fieldset) => {
return (pickerType == 'radios') ? Array.from(fieldset.querySelectorAll('input')).find((radio) => radio.checked).value : Array.from(fieldset.querySelectorAll('select'), (select) => select.value);
});
for(let optionLevel = 1, n = fieldsets.length; optionLevel < n; optionLevel++) {
const inputs = (pickerType == 'radios') ? fieldsets[optionLevel].querySelectorAll('input') : fieldsets[optionLevel].querySelectorAll('option');
inputs.forEach(input => {
input.disabled = (validCombo(input.value,optionLevel)) ? false : true;
if(pickerType == 'radios'){
const label = fieldsets[optionLevel].querySelector(`label[for="${input.id}"]`);
label.style.display = (input.disabled) ? "none" : ""; //Hide the option, or comment this line out and use the following lines to style it..
//label.style.opacity = (input.disabled) ? 0.5 : 1;
//label.style.borderStyle = (input.disabled) ? "dashed" : "solid";
//label.style.textDecoration = (input.disabled) ? "none" : "";
} else {
input.hidden = (validCombo(input.value,optionLevel)) ? false : true;
}
});
}
for (let optionLevel = 1, fieldsetsLength = fieldsets.length, change = false; optionLevel < fieldsetsLength && !change; optionLevel++) {
if(pickerType == 'radios'){
if(fieldsets[optionLevel].querySelector('input:checked').disabled === true) {
change = (fieldsets[optionLevel].querySelector('input:not(:disabled)').checked = true);
}
} else {
if(fieldsets[optionLevel].querySelector('option:checked').disabled === true) {
change = (fieldsets[optionLevel].querySelector('option:not(:disabled)').selected = "selected");
}
}
if(change) variantSelects.dispatchEvent(new Event('change', { bubbles: true }));
}
}