I am trying to build a logic to display shipping time on product page based on variant select.
#condition 1 if variant inventory quantity is greater than 0, show ‘ships immediately’
#condition 2 if variant inventory quantity is equal or less than 0 and other variant quantity is more than 0, show ‘out of stock, other variants ships immediately’.
#condition 3 if both variants are out of stock, show ‘ships in a week’
#condition 4 if there is no variants and inventory qty is less than 0, ‘show ships in a week’
so far i have tried this
variantInventory.forEach(function (v) {
if (v.id === variant.id) {
variant.inventory_quantity = v.inventory_quantity;
variant.inventory_management = v.inventory_management;
variant.inventory_policy = v.inventory_policy;
if(variant.inventory_quantity > 0){
$('#variant-inventory').text("Ships in 1-2 Business Days");
}
else if(variant.inventory_quantity <= 0 && variant.inventory_policy == 'continue'){
$('#variant-inventory').text("Ships in 5-7 business days.");
}
else if(variant.inventory_quantity <= 0 && variant.inventory_policy == 'continue' && variant.available == true){
$('#variant-inventory').text("Ships in 5-7 Business Days.Other variants available to ship immediately.");
}
}
});