@azzas/azzas-tracker-web 2.0.0 → 2.0.1-preview.0

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.
@@ -3150,14 +3150,20 @@ var AzzasTracker = function() {
3150
3150
  },
3151
3151
  payment_type: getPaymentType2,
3152
3152
  total_discount: function(context) {
3153
- var _context_orderForm, _context_orderForm1, _totalizers_find;
3153
+ var _ref;
3154
+ var _orderForm_totalizers_find, _orderForm_totalizers;
3154
3155
  if (context === null || context === void 0 ? void 0 : context.total_discount) return context.total_discount;
3155
- if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
3156
- var totalizers = context === null || context === void 0 ? void 0 : (_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totalizers;
3157
- var productDiscount = ((_totalizers_find = totalizers.find(function(t) {
3158
- return t.id === "Discounts";
3159
- })) === null || _totalizers_find === void 0 ? void 0 : _totalizers_find.value) || 0;
3160
- return Math.abs(productDiscount) / 100 || null;
3156
+ var orderForm = context === null || context === void 0 ? void 0 : context.orderForm;
3157
+ var items = orderForm === null || orderForm === void 0 ? void 0 : orderForm.items;
3158
+ if (!(items === null || items === void 0 ? void 0 : items.length) || typeof (orderForm === null || orderForm === void 0 ? void 0 : orderForm.value) !== "number") return null;
3159
+ var itemsFullValue = items.reduce(function(acc, item) {
3160
+ return acc + item.listPrice * item.quantity;
3161
+ }, 0);
3162
+ var shipping = (_ref = orderForm === null || orderForm === void 0 ? void 0 : (_orderForm_totalizers = orderForm.totalizers) === null || _orderForm_totalizers === void 0 ? void 0 : (_orderForm_totalizers_find = _orderForm_totalizers.find(function(t) {
3163
+ return t.id === "Shipping";
3164
+ })) === null || _orderForm_totalizers_find === void 0 ? void 0 : _orderForm_totalizers_find.value) !== null && _ref !== void 0 ? _ref : 0;
3165
+ var derived = itemsFullValue + shipping - orderForm.value;
3166
+ return derived > 0 ? derived / 100 : null;
3161
3167
  },
3162
3168
  subtotal: function(context) {
3163
3169
  var _context_orderForm, _context_orderForm1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azzas/azzas-tracker-web",
3
- "version": "2.0.0",
3
+ "version": "2.0.1-preview.0",
4
4
  "type": "module",
5
5
  "main": "./dist/mod.cjs",
6
6
  "module": "./dist/mod.js",