foodbot-cart-calculations 1.0.34 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -815,13 +815,15 @@ function getFreeProductOffer(cartObject, offer) {
|
|
|
815
815
|
offer.offer_products.offer_discount_products = offer.offer_products.offer_discount_products.map(Number);
|
|
816
816
|
|
|
817
817
|
var cartItem = carts;
|
|
818
|
-
|
|
819
818
|
if (offer.offer_products.order_modifiercost_use == 1) {
|
|
820
819
|
cartItem.sort(function (a, b) {
|
|
821
820
|
return a.item_price_with_modifier / a.quantity > b.item_price_with_modifier / b.quantity ? 1 : -1;
|
|
822
821
|
});
|
|
823
822
|
} else {
|
|
824
823
|
cartItem.sort(function (a, b) {
|
|
824
|
+
// If price is zero, move it to the end
|
|
825
|
+
if (a.item_price == 0) return 1;
|
|
826
|
+
if (b.item_price == 0) return -1;
|
|
825
827
|
return a.item_price / a.quantity > b.item_price / b.quantity ? 1 : -1;
|
|
826
828
|
});
|
|
827
829
|
}
|
package/package.json
CHANGED