Skip to content

Commit

Permalink
don't iterate when display is block
Browse files Browse the repository at this point in the history
  • Loading branch information
dedanade authored Apr 8, 2021
1 parent 917cf0e commit ae7a668
Showing 1 changed file with 39 additions and 33 deletions.
72 changes: 39 additions & 33 deletions embed-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ if (onePriceQty > 0) {
.value;
const selectPromoPrice = document.getElementById("selectPromoPrice");
const container = document.getElementById("variant_price_Quanity_container");
container.style.display = "block";
const select = container.querySelector("select");
select.setAttribute("required", "");
const PromoQtyArray = newVariantPrice.split(",");
const newPromoQtyArray = PromoQtyArray.filter((e) => e !== " = ₦");
for (var i = 0; i < newPromoQtyArray.length; i++) {
var opt = newPromoQtyArray[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
selectPromoPrice.appendChild(el);
if (container.style.display === "none") {
container.style.display = "block";
const select = container.querySelector("select");
select.setAttribute("required", "");
const PromoQtyArray = newVariantPrice.split(",");
const newPromoQtyArray = PromoQtyArray.filter((e) => e !== " = ₦");
for (var i = 0; i < newPromoQtyArray.length; i++) {
var opt = newPromoQtyArray[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
selectPromoPrice.appendChild(el);
}
}
selectPromoPrice.addEventListener("change", (e) => {
const justify_delivery_info = document.getElementById("all-del-info");
Expand All @@ -46,35 +48,39 @@ const newVariantColours = (

if (newVariantColours != "") {
const container = document.getElementById("variant_colours_container");
container.style.display = "block";
const select = container.querySelector("select");
select.setAttribute("required", "");
const selectColours = document.getElementById("selectColours");
const coloursOptions = newVariantColours.split(",");
for (var i = 0; i < coloursOptions.length; i++) {
var opt = coloursOptions[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
selectColours.appendChild(el);
if (container.style.display === "none") {
container.style.display = "block";
const select = container.querySelector("select");
select.setAttribute("required", "");
const selectColours = document.getElementById("selectColours");
const coloursOptions = newVariantColours.split(",");
for (var i = 0; i < coloursOptions.length; i++) {
var opt = coloursOptions[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
selectColours.appendChild(el);
}
}
}

const newVariantSizes = (document.getElementById("product-variant-size") || {})
.value;
if (newVariantSizes != "") {
const container = document.getElementById("variant_size_container");
container.style.display = "block";
const select = container.querySelector("select");
select.setAttribute("required", "");
const selectSizes = document.getElementById("selectSizes");
const sizesOptions = newVariantSizes.split(",");
for (var i = 0; i < sizesOptions.length; i++) {
var opt = sizesOptions[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
selectSizes.appendChild(el);
if (container.style.display === "none") {
container.style.display = "block";
const select = container.querySelector("select");
select.setAttribute("required", "");
const selectSizes = document.getElementById("selectSizes");
const sizesOptions = newVariantSizes.split(",");
for (var i = 0; i < sizesOptions.length; i++) {
var opt = sizesOptions[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
selectSizes.appendChild(el);
}
}
}

Expand Down

0 comments on commit ae7a668

Please sign in to comment.