vanilli-shop-client
Advanced tools
Comparing version 0.9.17 to 0.9.18
@@ -8,2 +8,3 @@ export interface IShippingMethodDto { | ||
fee?: number; | ||
freeShippingThreshold?: number; | ||
estimationInDays: number; | ||
@@ -10,0 +11,0 @@ } |
@@ -45,13 +45,8 @@ "use strict"; | ||
CartStore.prototype.calculateSubTotal = function () { | ||
var _a; | ||
var total = 0; | ||
for (var _i = 0, _b = this.cartItems; _i < _b.length; _i++) { | ||
var item = _b[_i]; | ||
for (var _i = 0, _a = this.cartItems; _i < _a.length; _i++) { | ||
var item = _a[_i]; | ||
var itemTotal = cart_1.CartItem.getTotal(item); | ||
total = total + itemTotal; | ||
} | ||
var shippingFee = (_a = this.rootStore.shippingStore.selectedMethod) === null || _a === void 0 ? void 0 : _a.fee; | ||
if (shippingFee) { | ||
total = total + shippingFee; | ||
} | ||
return total; | ||
@@ -62,2 +57,9 @@ }; | ||
if (shippingMethod) { | ||
var freeShippingThreshold = shippingMethod.freeShippingThreshold; | ||
if (freeShippingThreshold) { | ||
var total = this.calculateSubTotal(); | ||
if (total >= freeShippingThreshold) { | ||
return 0; | ||
} | ||
} | ||
return shippingMethod.fee || 0; | ||
@@ -68,3 +70,5 @@ } | ||
CartStore.prototype.calculateTotal = function () { | ||
var total = this.calculateSubTotal(); | ||
var subTotal = this.calculateSubTotal(); | ||
var shipping = this.calculateShipping(); | ||
var total = subTotal + shipping; | ||
var discount = this.calculateDiscount(); | ||
@@ -81,3 +85,5 @@ if (discount) { | ||
} | ||
var total = this.calculateSubTotal(); | ||
var subTotal = this.calculateSubTotal(); | ||
var shipping = this.calculateShipping(); | ||
var total = subTotal + shipping; | ||
var discount = discountPercentage / 100; | ||
@@ -84,0 +90,0 @@ return total * discount; |
{ | ||
"name": "vanilli-shop-client", | ||
"version": "0.9.17", | ||
"version": "0.9.18", | ||
"description": "Client for Vanilli Shop API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -8,2 +8,3 @@ export interface IShippingMethodDto { | ||
fee?: number, | ||
freeShippingThreshold?: number, | ||
estimationInDays: number | ||
@@ -10,0 +11,0 @@ } |
@@ -36,8 +36,2 @@ import BaseStore from "./base-store"; | ||
const shippingFee = this.rootStore.shippingStore.selectedMethod?.fee; | ||
if (shippingFee) { | ||
total = total + shippingFee; | ||
} | ||
return total; | ||
@@ -50,2 +44,12 @@ } | ||
if (shippingMethod) { | ||
const freeShippingThreshold = shippingMethod.freeShippingThreshold; | ||
if (freeShippingThreshold) { | ||
const total = this.calculateSubTotal(); | ||
if (total >= freeShippingThreshold) { | ||
return 0; | ||
} | ||
} | ||
return shippingMethod.fee || 0; | ||
@@ -58,3 +62,5 @@ } | ||
calculateTotal(): number { | ||
const total = this.calculateSubTotal(); | ||
const subTotal = this.calculateSubTotal(); | ||
const shipping = this.calculateShipping(); | ||
const total = subTotal + shipping; | ||
const discount = this.calculateDiscount(); | ||
@@ -76,3 +82,5 @@ | ||
const total = this.calculateSubTotal(); | ||
const subTotal = this.calculateSubTotal(); | ||
const shipping = this.calculateShipping(); | ||
const total = subTotal + shipping; | ||
const discount = discountPercentage / 100; | ||
@@ -79,0 +87,0 @@ return total * discount; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
149418
3437