This works for 1 SKU:
- Code: Select all
ns_count = 0;
for(ns=0; ns<ss_sku.length; ns++){
if(ss_sku[ns]=="widget1"){
ns_count+= ss_quantity[ns];
}
}
if (button == "8") {
if(ns_count > 6){
alert("Maximum quantity is 6 Widget1 packages per order, please adjust your quantity accordingly.");
return false;
}
}
================================
But it will not work for more than 1 SKU (for a group). Tried using OR "||" but it ends up checking random SKUs and shows the alert for SKUs not listed. Example of code that does not work:
- Code: Select all
//SKU Group
ns_count = 0;
for(ns=0; ns<ss_sku.length; ns++){
if(ss_sku[ns]=="widget1" || "widget2"){
ns_count+= ss_quantity[ns];
}
}
if (button == "8") {
if(ns_count > 8){
alert("Maximum quantity for this group is 8 Widget1 or Widget2 packages per order, please adjust your quantities for these two items accordingly.");
return false;
}
}
Any help would be appreciated. I do not know javascript well and could not find a solution online.
Thanks!