@storepecker/storefront-core 2.10.0 → 2.10.1
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.
- package/dist/api/index.cjs +20 -20
- package/dist/api/index.d.cts +8 -15
- package/dist/api/index.d.ts +8 -15
- package/dist/api/index.js +2 -2
- package/dist/{buy-now-kII0KrhP.d.ts → buy-now-CDug6LJ_.d.ts} +1 -1
- package/dist/{buy-now-B_15RUVT.d.cts → buy-now-DrKY5_9R.d.cts} +1 -1
- package/dist/checkout/index.cjs +92 -98
- package/dist/checkout/index.d.cts +17 -30
- package/dist/checkout/index.d.ts +17 -30
- package/dist/checkout/index.js +48 -63
- package/dist/{pincode-Ch3bZSJz.d.cts → checkout-totals-CbmXM9L7.d.cts} +42 -1
- package/dist/{pincode-CHM-ZD3H.d.ts → checkout-totals-DU8l-Wyb.d.ts} +42 -1
- package/dist/{chunk-NQZ5GUOG.cjs → chunk-3YPE6UPC.cjs} +24 -16
- package/dist/{chunk-Y4RNRPBC.js → chunk-DZPK7GPG.js} +58 -2
- package/dist/{chunk-TH7OAMGC.js → chunk-E4D4XOAE.js} +24 -16
- package/dist/{chunk-NRPK5GCJ.cjs → chunk-EFYAFXIS.cjs} +3 -3
- package/dist/{chunk-NOT6VKXA.cjs → chunk-H6UZTS5O.cjs} +67 -23
- package/dist/{chunk-ZAWZ3RB6.js → chunk-NNE42NMP.js} +1 -1
- package/dist/{chunk-QED6QJZC.cjs → chunk-PN6KH5PX.cjs} +59 -1
- package/dist/{chunk-QQHQTBAM.js → chunk-QSRVMOXT.js} +48 -6
- package/dist/{collections-CXgOv5_G.d.cts → collections-CKNFcE2d.d.cts} +1 -1
- package/dist/{collections-CNh2OGbl.d.ts → collections-CtRKsWVx.d.ts} +1 -1
- package/dist/components/digital-product-download-modal.d.cts +2 -2
- package/dist/components/digital-product-download-modal.d.ts +2 -2
- package/dist/components/index.d.cts +4 -5
- package/dist/components/index.d.ts +4 -5
- package/dist/components/share-button.d.cts +1 -1
- package/dist/components/share-button.d.ts +1 -1
- package/dist/components/theme-data-initializer.d.cts +4 -5
- package/dist/components/theme-data-initializer.d.ts +4 -5
- package/dist/hooks/index.cjs +62 -58
- package/dist/hooks/index.d.cts +9 -7
- package/dist/hooks/index.d.ts +9 -7
- package/dist/hooks/index.js +8 -5
- package/dist/{instagram-DalreBu6.d.cts → instagram-CSzrxk10.d.cts} +8 -2
- package/dist/{instagram-BADLnNQ3.d.ts → instagram-CagTLmyq.d.ts} +8 -2
- package/dist/models/index.d.cts +6 -7
- package/dist/models/index.d.ts +6 -7
- package/dist/orders-B6BmHCJN.d.ts +337 -0
- package/dist/orders-ZKP0lqRN.d.cts +337 -0
- package/dist/{pixelEvents-Ds6fwS9t.d.ts → pixelEvents-DqJ_CEEr.d.ts} +3 -4
- package/dist/{pixelEvents-COqZIgTu.d.cts → pixelEvents-bahgVW4_.d.cts} +3 -4
- package/dist/{product-D9liEtl4.d.cts → product-D4kol-Z-.d.cts} +26 -2
- package/dist/{product-D9liEtl4.d.ts → product-D4kol-Z-.d.ts} +26 -2
- package/dist/store/index.cjs +20 -30
- package/dist/store/index.d.cts +21 -7
- package/dist/store/index.d.ts +21 -7
- package/dist/store/index.js +9 -26
- package/dist/utils/index.cjs +2 -2
- package/dist/utils/index.d.cts +14 -8
- package/dist/utils/index.d.ts +14 -8
- package/dist/utils/index.js +1 -1
- package/dist/{wishlist-Cj0sQxiY.d.ts → wishlist-L3fM5-ie.d.ts} +1 -1
- package/dist/{wishlist-BakHvIFN.d.cts → wishlist-_0x0r1jt.d.cts} +1 -1
- package/package.json +1 -1
- package/dist/cart-DZq1ZEnE.d.ts +0 -153
- package/dist/cart-DwMFBmpC.d.cts +0 -153
- package/dist/orders-B3G4CyhH.d.cts +0 -166
- package/dist/orders-Bl-Slh72.d.ts +0 -166
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as Yup from 'yup';
|
|
2
|
-
export { A as AddressFormat, a as AddressSchemaMessages, D as DEFAULT_ADDRESS_SCHEMA_MESSAGES, I as INVALID_PINCODE, N as NO_POSTAL_CODE, P as PINCODE_DEBOUNCE_MS,
|
|
3
|
-
import {
|
|
4
|
-
import { O as Order } from '../orders-B3G4CyhH.cjs';
|
|
2
|
+
export { A as AddressFormat, a as AddressSchemaMessages, C as CartLike, b as CheckoutTotals, D as DEFAULT_ADDRESS_SCHEMA_MESSAGES, I as INVALID_PINCODE, N as NO_POSTAL_CODE, P as PINCODE_DEBOUNCE_MS, c as PINCODE_MIN_LENGTH, d as PINCODE_VALIDATION_UNAVAILABLE, e as PincodeCheck, f as PincodeMatch, R as RawAddressData, g as buildAddressFormat, h as buildAddressSchema, i as calculateCartTotals, j as clearPincodeCache, k as findStateByName, l as findSubdivision, m as getAreaOptions, n as getCustomizationPrice, o as getPincodeError, p as getPostcodeHint, q as joinAddressLines, r as loadAddressFormat, s as lowerLabel, t as normalizePostcode, u as sanitizePincode, v as usableEmail, w as validatePincode } from '../checkout-totals-CbmXM9L7.cjs';
|
|
3
|
+
import { c as Coupon, O as Order } from '../orders-ZKP0lqRN.cjs';
|
|
5
4
|
import '../pincode-8u7yWLpQ.cjs';
|
|
6
|
-
import '../product-
|
|
5
|
+
import '../product-D4kol-Z-.cjs';
|
|
7
6
|
import 'react-toastify';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -151,20 +150,6 @@ declare function isValidNumber(input: string, code: string): boolean;
|
|
|
151
150
|
*/
|
|
152
151
|
declare function sanitizePhoneInput(raw: string, countryCode: string): string;
|
|
153
152
|
|
|
154
|
-
interface CartTotals {
|
|
155
|
-
totalSellingAmount: number;
|
|
156
|
-
discountAmount: number;
|
|
157
|
-
isCartEmpty: boolean;
|
|
158
|
-
allInclusiveTax: boolean;
|
|
159
|
-
exclusiveTaxAmount: number;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Calculate cart totals from the cart data.
|
|
163
|
-
* Computes subtotal (based on actual_price or selling_price), discount amount,
|
|
164
|
-
* and tax breakdown (inclusive vs exclusive).
|
|
165
|
-
*/
|
|
166
|
-
declare function calculateCartTotals(cart: Cart.Root | null): CartTotals;
|
|
167
|
-
|
|
168
153
|
interface CouponCallbacks {
|
|
169
154
|
onCartRefresh: () => void | Promise<void>;
|
|
170
155
|
}
|
|
@@ -290,29 +275,31 @@ interface PaymentStatusCallbacks {
|
|
|
290
275
|
onFailure: () => void;
|
|
291
276
|
onOrderLoaded?: (order: Order.OrderSummary) => void;
|
|
292
277
|
}
|
|
278
|
+
interface PaymentStatusOptions {
|
|
279
|
+
isPublic?: boolean;
|
|
280
|
+
reportFailure?: boolean;
|
|
281
|
+
}
|
|
282
|
+
/** Whether a Stripe status payload means the order is paid. */
|
|
283
|
+
declare function isStripePaid(data?: Partial<Order.StripePaymentStatus> | null): boolean;
|
|
284
|
+
/** Whether a Tabby status payload means the order is paid. */
|
|
285
|
+
declare function isTabbyPaid(data?: Partial<Order.TabbyPaymentStatus> | null): boolean;
|
|
293
286
|
/**
|
|
294
287
|
* Check PhonePe payment status after redirect back from PhonePe.
|
|
295
288
|
*/
|
|
296
|
-
declare function checkPhonepeReturnStatus(transactionId: string, callbacks: PaymentStatusCallbacks, options?:
|
|
297
|
-
isPublic?: boolean;
|
|
298
|
-
}): Promise<void>;
|
|
289
|
+
declare function checkPhonepeReturnStatus(transactionId: string, callbacks: PaymentStatusCallbacks, options?: PaymentStatusOptions): Promise<void>;
|
|
299
290
|
/**
|
|
300
291
|
* Check PhonePe payment status with order details for pixel events.
|
|
301
292
|
*/
|
|
302
|
-
declare function checkPhonepeReturnStatusWithOrder(transactionId: string, orderNumber: number, callbacks: PaymentStatusCallbacks, options?:
|
|
303
|
-
isPublic?: boolean;
|
|
304
|
-
}): Promise<void>;
|
|
293
|
+
declare function checkPhonepeReturnStatusWithOrder(transactionId: string, orderNumber: number, callbacks: PaymentStatusCallbacks, options?: PaymentStatusOptions): Promise<void>;
|
|
305
294
|
/**
|
|
306
295
|
* Check Stripe payment status after redirect back from Stripe checkout.
|
|
307
296
|
*/
|
|
308
|
-
declare function checkStripeReturnStatus(sessionId: string, orderNumber: number, paymentLinkUrl: string, callbacks: PaymentStatusCallbacks, options?:
|
|
309
|
-
isPublic?: boolean;
|
|
310
|
-
}): Promise<void>;
|
|
297
|
+
declare function checkStripeReturnStatus(sessionId: string, orderNumber: number, paymentLinkUrl: string, callbacks: PaymentStatusCallbacks, options?: PaymentStatusOptions): Promise<void>;
|
|
311
298
|
/**
|
|
312
299
|
* Check Tabby payment status after redirect back from Tabby.
|
|
313
300
|
*/
|
|
314
|
-
declare function checkTabbyReturnStatus(orderNumber: number, callbacks: PaymentStatusCallbacks, options?: {
|
|
315
|
-
|
|
301
|
+
declare function checkTabbyReturnStatus(orderNumber: number, callbacks: PaymentStatusCallbacks, options?: PaymentStatusOptions & {
|
|
302
|
+
paymentId?: string | null;
|
|
316
303
|
}): Promise<void>;
|
|
317
304
|
|
|
318
|
-
export { type AddressFormValues, type
|
|
305
|
+
export { type AddressFormValues, type CouponCallbacks, IP_API_CACHE_KEY, type PaymentCallbacks, type PaymentStatusCallbacks, type PaymentStatusOptions, type PlacementErrorAction, type PlacementErrorInfo, addressFormInitialValues, addressValidationSchema, applyCheckoutCoupon, buildAddressPayload, buildSubmitPayload, checkPhonepeReturnStatus, checkPhonepeReturnStatusWithOrder, checkStripeReturnStatus, checkTabbyReturnStatus, clearAddressFormSession, decodeAddress, describePlacementError, encodeAddress, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, isStripePaid, isTabbyPaid, isValidNumber, isValidPhoneNumber, loadAddressFormFromSession, openRazorpayCheckout, parseEditAddress, processPayment, removeCheckoutCoupon, sanitizePhoneInput, sanitizePhoneNumber, saveAddressFormToSession };
|
package/dist/checkout/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as Yup from 'yup';
|
|
2
|
-
export { A as AddressFormat, a as AddressSchemaMessages, D as DEFAULT_ADDRESS_SCHEMA_MESSAGES, I as INVALID_PINCODE, N as NO_POSTAL_CODE, P as PINCODE_DEBOUNCE_MS,
|
|
3
|
-
import {
|
|
4
|
-
import { O as Order } from '../orders-Bl-Slh72.js';
|
|
2
|
+
export { A as AddressFormat, a as AddressSchemaMessages, C as CartLike, b as CheckoutTotals, D as DEFAULT_ADDRESS_SCHEMA_MESSAGES, I as INVALID_PINCODE, N as NO_POSTAL_CODE, P as PINCODE_DEBOUNCE_MS, c as PINCODE_MIN_LENGTH, d as PINCODE_VALIDATION_UNAVAILABLE, e as PincodeCheck, f as PincodeMatch, R as RawAddressData, g as buildAddressFormat, h as buildAddressSchema, i as calculateCartTotals, j as clearPincodeCache, k as findStateByName, l as findSubdivision, m as getAreaOptions, n as getCustomizationPrice, o as getPincodeError, p as getPostcodeHint, q as joinAddressLines, r as loadAddressFormat, s as lowerLabel, t as normalizePostcode, u as sanitizePincode, v as usableEmail, w as validatePincode } from '../checkout-totals-DU8l-Wyb.js';
|
|
3
|
+
import { c as Coupon, O as Order } from '../orders-B6BmHCJN.js';
|
|
5
4
|
import '../pincode-8u7yWLpQ.js';
|
|
6
|
-
import '../product-
|
|
5
|
+
import '../product-D4kol-Z-.js';
|
|
7
6
|
import 'react-toastify';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -151,20 +150,6 @@ declare function isValidNumber(input: string, code: string): boolean;
|
|
|
151
150
|
*/
|
|
152
151
|
declare function sanitizePhoneInput(raw: string, countryCode: string): string;
|
|
153
152
|
|
|
154
|
-
interface CartTotals {
|
|
155
|
-
totalSellingAmount: number;
|
|
156
|
-
discountAmount: number;
|
|
157
|
-
isCartEmpty: boolean;
|
|
158
|
-
allInclusiveTax: boolean;
|
|
159
|
-
exclusiveTaxAmount: number;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Calculate cart totals from the cart data.
|
|
163
|
-
* Computes subtotal (based on actual_price or selling_price), discount amount,
|
|
164
|
-
* and tax breakdown (inclusive vs exclusive).
|
|
165
|
-
*/
|
|
166
|
-
declare function calculateCartTotals(cart: Cart.Root | null): CartTotals;
|
|
167
|
-
|
|
168
153
|
interface CouponCallbacks {
|
|
169
154
|
onCartRefresh: () => void | Promise<void>;
|
|
170
155
|
}
|
|
@@ -290,29 +275,31 @@ interface PaymentStatusCallbacks {
|
|
|
290
275
|
onFailure: () => void;
|
|
291
276
|
onOrderLoaded?: (order: Order.OrderSummary) => void;
|
|
292
277
|
}
|
|
278
|
+
interface PaymentStatusOptions {
|
|
279
|
+
isPublic?: boolean;
|
|
280
|
+
reportFailure?: boolean;
|
|
281
|
+
}
|
|
282
|
+
/** Whether a Stripe status payload means the order is paid. */
|
|
283
|
+
declare function isStripePaid(data?: Partial<Order.StripePaymentStatus> | null): boolean;
|
|
284
|
+
/** Whether a Tabby status payload means the order is paid. */
|
|
285
|
+
declare function isTabbyPaid(data?: Partial<Order.TabbyPaymentStatus> | null): boolean;
|
|
293
286
|
/**
|
|
294
287
|
* Check PhonePe payment status after redirect back from PhonePe.
|
|
295
288
|
*/
|
|
296
|
-
declare function checkPhonepeReturnStatus(transactionId: string, callbacks: PaymentStatusCallbacks, options?:
|
|
297
|
-
isPublic?: boolean;
|
|
298
|
-
}): Promise<void>;
|
|
289
|
+
declare function checkPhonepeReturnStatus(transactionId: string, callbacks: PaymentStatusCallbacks, options?: PaymentStatusOptions): Promise<void>;
|
|
299
290
|
/**
|
|
300
291
|
* Check PhonePe payment status with order details for pixel events.
|
|
301
292
|
*/
|
|
302
|
-
declare function checkPhonepeReturnStatusWithOrder(transactionId: string, orderNumber: number, callbacks: PaymentStatusCallbacks, options?:
|
|
303
|
-
isPublic?: boolean;
|
|
304
|
-
}): Promise<void>;
|
|
293
|
+
declare function checkPhonepeReturnStatusWithOrder(transactionId: string, orderNumber: number, callbacks: PaymentStatusCallbacks, options?: PaymentStatusOptions): Promise<void>;
|
|
305
294
|
/**
|
|
306
295
|
* Check Stripe payment status after redirect back from Stripe checkout.
|
|
307
296
|
*/
|
|
308
|
-
declare function checkStripeReturnStatus(sessionId: string, orderNumber: number, paymentLinkUrl: string, callbacks: PaymentStatusCallbacks, options?:
|
|
309
|
-
isPublic?: boolean;
|
|
310
|
-
}): Promise<void>;
|
|
297
|
+
declare function checkStripeReturnStatus(sessionId: string, orderNumber: number, paymentLinkUrl: string, callbacks: PaymentStatusCallbacks, options?: PaymentStatusOptions): Promise<void>;
|
|
311
298
|
/**
|
|
312
299
|
* Check Tabby payment status after redirect back from Tabby.
|
|
313
300
|
*/
|
|
314
|
-
declare function checkTabbyReturnStatus(orderNumber: number, callbacks: PaymentStatusCallbacks, options?: {
|
|
315
|
-
|
|
301
|
+
declare function checkTabbyReturnStatus(orderNumber: number, callbacks: PaymentStatusCallbacks, options?: PaymentStatusOptions & {
|
|
302
|
+
paymentId?: string | null;
|
|
316
303
|
}): Promise<void>;
|
|
317
304
|
|
|
318
|
-
export { type AddressFormValues, type
|
|
305
|
+
export { type AddressFormValues, type CouponCallbacks, IP_API_CACHE_KEY, type PaymentCallbacks, type PaymentStatusCallbacks, type PaymentStatusOptions, type PlacementErrorAction, type PlacementErrorInfo, addressFormInitialValues, addressValidationSchema, applyCheckoutCoupon, buildAddressPayload, buildSubmitPayload, checkPhonepeReturnStatus, checkPhonepeReturnStatusWithOrder, checkStripeReturnStatus, checkTabbyReturnStatus, clearAddressFormSession, decodeAddress, describePlacementError, encodeAddress, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, isStripePaid, isTabbyPaid, isValidNumber, isValidPhoneNumber, loadAddressFormFromSession, openRazorpayCheckout, parseEditAddress, processPayment, removeCheckoutCoupon, sanitizePhoneInput, sanitizePhoneNumber, saveAddressFormToSession };
|
package/dist/checkout/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { DEFAULT_ADDRESS_SCHEMA_MESSAGES, INVALID_PINCODE, NO_POSTAL_CODE, PINCODE_DEBOUNCE_MS, PINCODE_MIN_LENGTH, PINCODE_VALIDATION_UNAVAILABLE, applyCheckoutCoupon, buildAddressFormat, buildAddressSchema, clearPincodeCache, fetchAppliedCoupon, fetchAvailableCoupons, findStateByName, findSubdivision, getAreaOptions, getPincodeError, getPostcodeHint, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, isValidNumber, joinAddressLines, loadAddressFormat, lowerLabel, normalizePostcode, openRazorpayCheckout, processPayment, removeCheckoutCoupon, sanitizePhoneInput, sanitizePincode, usableEmail, validatePincode } from '../chunk-
|
|
1
|
+
export { DEFAULT_ADDRESS_SCHEMA_MESSAGES, INVALID_PINCODE, NO_POSTAL_CODE, PINCODE_DEBOUNCE_MS, PINCODE_MIN_LENGTH, PINCODE_VALIDATION_UNAVAILABLE, applyCheckoutCoupon, buildAddressFormat, buildAddressSchema, calculateCartTotals, clearPincodeCache, fetchAppliedCoupon, fetchAvailableCoupons, findStateByName, findSubdivision, getAreaOptions, getCustomizationPrice, getPincodeError, getPostcodeHint, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, isValidNumber, joinAddressLines, loadAddressFormat, lowerLabel, normalizePostcode, openRazorpayCheckout, processPayment, removeCheckoutCoupon, sanitizePhoneInput, sanitizePincode, usableEmail, validatePincode } from '../chunk-DZPK7GPG.js';
|
|
2
2
|
import '../chunk-A7EI7XLU.js';
|
|
3
3
|
import { pixelEvents } from '../chunk-VAU5OL72.js';
|
|
4
|
-
import { checkPhonepePaymentStatusPublic, checkPhonepePaymentStatus, getPublicOrderDetailsByNumber, getOrderDetailsByNumber, getStripePaymentStatusPublic, getStripePaymentStatus, verifyTabbyPayment } from '../chunk-KCLVR6G5.js';
|
|
4
|
+
import { checkPhonepePaymentStatusPublic, checkPhonepePaymentStatus, getPublicOrderDetailsByNumber, getOrderDetailsByNumber, getStripePaymentStatusPublic, getStripePaymentStatus, verifyTabbyPayment, tabbyPaymentFailure, publicPhonepeOrderFailure, phonepePaymentFailure } from '../chunk-KCLVR6G5.js';
|
|
5
5
|
export { IP_API_CACHE_KEY, addressFormInitialValues, addressValidationSchema, buildAddressPayload, buildSubmitPayload, clearAddressFormSession, decodeAddress, encodeAddress, isValidPhoneNumber, loadAddressFormFromSession, parseEditAddress, sanitizePhoneNumber, saveAddressFormToSession } from '../chunk-ELP23UGF.js';
|
|
6
6
|
import '../chunk-OSM73ETC.js';
|
|
7
7
|
import '../chunk-3SYYP3XV.js';
|
|
@@ -9,42 +9,6 @@ import '../chunk-WEMNXIRS.js';
|
|
|
9
9
|
import '../chunk-BQ256JKN.js';
|
|
10
10
|
import '../chunk-JQMLHRWL.js';
|
|
11
11
|
|
|
12
|
-
// src/checkout/cart-calculations.ts
|
|
13
|
-
function calculateCartTotals(cart) {
|
|
14
|
-
if (!cart) {
|
|
15
|
-
return {
|
|
16
|
-
totalSellingAmount: 0,
|
|
17
|
-
discountAmount: 0,
|
|
18
|
-
isCartEmpty: true,
|
|
19
|
-
allInclusiveTax: true,
|
|
20
|
-
exclusiveTaxAmount: 0
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
let totalSellingAmount = 0;
|
|
24
|
-
let discountAmount = 0;
|
|
25
|
-
let exclusiveTaxAmount = 0;
|
|
26
|
-
let allInclusiveTax = true;
|
|
27
|
-
cart.product_variants?.forEach((item) => {
|
|
28
|
-
const quantity = cart.products_quantity[item.id] || 0;
|
|
29
|
-
const actualPrice = Number(item.actual_price);
|
|
30
|
-
const sellingPrice = Number(item.selling_price);
|
|
31
|
-
const variant = item;
|
|
32
|
-
totalSellingAmount += actualPrice ? actualPrice * quantity : sellingPrice * quantity;
|
|
33
|
-
discountAmount += actualPrice ? (actualPrice - sellingPrice) * quantity : 0;
|
|
34
|
-
if (!variant.is_tax_inclusive_price) {
|
|
35
|
-
allInclusiveTax = false;
|
|
36
|
-
exclusiveTaxAmount += Number(variant.total_tax_price || 0) * quantity;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
return {
|
|
40
|
-
totalSellingAmount,
|
|
41
|
-
discountAmount,
|
|
42
|
-
isCartEmpty: !cart.product_variants?.length,
|
|
43
|
-
allInclusiveTax,
|
|
44
|
-
exclusiveTaxAmount
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
12
|
// src/checkout/placement-error.ts
|
|
49
13
|
function describePlacementError(error) {
|
|
50
14
|
const code = error?.response?.data?.error_code || error?.response?.data?.code;
|
|
@@ -87,57 +51,73 @@ function describePlacementError(error) {
|
|
|
87
51
|
}
|
|
88
52
|
|
|
89
53
|
// src/checkout/payment-status.ts
|
|
54
|
+
async function reportPhonepeFailure(transactionId, order, isPublic) {
|
|
55
|
+
try {
|
|
56
|
+
if (isPublic) {
|
|
57
|
+
await publicPhonepeOrderFailure({ id: transactionId, status: "REJECTED" });
|
|
58
|
+
} else if (order) {
|
|
59
|
+
await phonepePaymentFailure({ order_id: order.id, phonepe_transaction_id: transactionId });
|
|
60
|
+
}
|
|
61
|
+
} catch {
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function isStripePaid(data) {
|
|
65
|
+
return data?.payment_status === "paid" || data?.status === "complete" || data?.order_status === "paid" || data?.success === true;
|
|
66
|
+
}
|
|
67
|
+
function isTabbyPaid(data) {
|
|
68
|
+
return data?.order_status === "paid" || data?.order_status === "confirmed" || data?.order_status === "success" || data?.status === "paid";
|
|
69
|
+
}
|
|
90
70
|
async function checkPhonepeReturnStatus(transactionId, callbacks, options) {
|
|
91
71
|
try {
|
|
92
72
|
const checkStatus = options?.isPublic ? checkPhonepePaymentStatusPublic : checkPhonepePaymentStatus;
|
|
93
73
|
const response = await checkStatus(transactionId);
|
|
94
74
|
if (response.data.success) {
|
|
95
75
|
callbacks.onSuccess(void 0);
|
|
96
|
-
|
|
97
|
-
callbacks.onFailure();
|
|
76
|
+
return;
|
|
98
77
|
}
|
|
99
78
|
} catch {
|
|
100
|
-
callbacks.onFailure();
|
|
101
79
|
}
|
|
80
|
+
if (options?.reportFailure) await reportPhonepeFailure(transactionId, null, options.isPublic);
|
|
81
|
+
callbacks.onFailure();
|
|
102
82
|
}
|
|
103
83
|
async function checkPhonepeReturnStatusWithOrder(transactionId, orderNumber, callbacks, options) {
|
|
84
|
+
const checkStatus = options?.isPublic ? checkPhonepePaymentStatusPublic : checkPhonepePaymentStatus;
|
|
85
|
+
const getOrder = options?.isPublic ? getPublicOrderDetailsByNumber : getOrderDetailsByNumber;
|
|
86
|
+
let order = null;
|
|
104
87
|
try {
|
|
105
|
-
const checkStatus = options?.isPublic ? checkPhonepePaymentStatusPublic : checkPhonepePaymentStatus;
|
|
106
|
-
const getOrder = options?.isPublic ? getPublicOrderDetailsByNumber : getOrderDetailsByNumber;
|
|
107
88
|
const [paymentResponse, orderResponse] = await Promise.all([
|
|
108
89
|
checkStatus(transactionId),
|
|
109
90
|
getOrder(orderNumber)
|
|
110
91
|
]);
|
|
111
|
-
|
|
92
|
+
order = orderResponse.data;
|
|
112
93
|
callbacks.onOrderLoaded?.(order);
|
|
113
94
|
if (paymentResponse.data.success) {
|
|
114
95
|
pixelEvents.purchase(order);
|
|
115
96
|
pixelEvents.checkoutCompleted(order);
|
|
116
97
|
callbacks.onSuccess(order);
|
|
117
|
-
|
|
118
|
-
callbacks.onFailure();
|
|
98
|
+
return;
|
|
119
99
|
}
|
|
120
100
|
} catch {
|
|
121
|
-
callbacks.onFailure();
|
|
122
101
|
}
|
|
102
|
+
if (options?.reportFailure) await reportPhonepeFailure(transactionId, order, options.isPublic);
|
|
103
|
+
callbacks.onFailure();
|
|
123
104
|
}
|
|
124
105
|
async function checkStripeReturnStatus(sessionId, orderNumber, paymentLinkUrl, callbacks, options) {
|
|
125
106
|
try {
|
|
126
107
|
const getStatus = options?.isPublic ? getStripePaymentStatusPublic : getStripePaymentStatus;
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
108
|
+
const getOrder = options?.isPublic ? getPublicOrderDetailsByNumber : getOrderDetailsByNumber;
|
|
109
|
+
const [response, orderResponse] = await Promise.all([
|
|
110
|
+
getStatus(sessionId, orderNumber, paymentLinkUrl),
|
|
111
|
+
getOrder(orderNumber).catch(() => null)
|
|
112
|
+
]);
|
|
113
|
+
const order = orderResponse?.data;
|
|
114
|
+
if (order) callbacks.onOrderLoaded?.(order);
|
|
115
|
+
if (isStripePaid(response.data)) {
|
|
116
|
+
if (order) {
|
|
135
117
|
pixelEvents.purchase(order);
|
|
136
118
|
pixelEvents.checkoutCompleted(order);
|
|
137
|
-
callbacks.onSuccess(order);
|
|
138
|
-
} catch {
|
|
139
|
-
callbacks.onSuccess(void 0);
|
|
140
119
|
}
|
|
120
|
+
callbacks.onSuccess(order ?? void 0);
|
|
141
121
|
} else {
|
|
142
122
|
callbacks.onFailure();
|
|
143
123
|
}
|
|
@@ -146,6 +126,7 @@ async function checkStripeReturnStatus(sessionId, orderNumber, paymentLinkUrl, c
|
|
|
146
126
|
}
|
|
147
127
|
}
|
|
148
128
|
async function checkTabbyReturnStatus(orderNumber, callbacks, options) {
|
|
129
|
+
let tabbyPaymentId = options?.paymentId || void 0;
|
|
149
130
|
try {
|
|
150
131
|
const getOrder = options?.isPublic ? getPublicOrderDetailsByNumber : getOrderDetailsByNumber;
|
|
151
132
|
const [response, orderResponse] = await Promise.all([
|
|
@@ -154,18 +135,22 @@ async function checkTabbyReturnStatus(orderNumber, callbacks, options) {
|
|
|
154
135
|
]);
|
|
155
136
|
const order = orderResponse?.data;
|
|
156
137
|
if (order) callbacks.onOrderLoaded?.(order);
|
|
157
|
-
if (response.data
|
|
138
|
+
if (isTabbyPaid(response.data)) {
|
|
158
139
|
if (order) {
|
|
159
140
|
pixelEvents.purchase(order);
|
|
160
141
|
pixelEvents.checkoutCompleted(order);
|
|
161
142
|
}
|
|
162
143
|
callbacks.onSuccess(order ?? void 0);
|
|
163
|
-
|
|
164
|
-
callbacks.onFailure();
|
|
144
|
+
return;
|
|
165
145
|
}
|
|
146
|
+
tabbyPaymentId = tabbyPaymentId || response.data.payment_id;
|
|
166
147
|
} catch {
|
|
167
|
-
callbacks.onFailure();
|
|
168
148
|
}
|
|
149
|
+
if (options?.reportFailure && tabbyPaymentId) {
|
|
150
|
+
await tabbyPaymentFailure(tabbyPaymentId).catch(() => {
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
callbacks.onFailure();
|
|
169
154
|
}
|
|
170
155
|
|
|
171
|
-
export {
|
|
156
|
+
export { checkPhonepeReturnStatus, checkPhonepeReturnStatusWithOrder, checkStripeReturnStatus, checkTabbyReturnStatus, describePlacementError, isStripePaid, isTabbyPaid };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as Yup from 'yup';
|
|
2
2
|
import { P as Pincode } from './pincode-8u7yWLpQ.cjs';
|
|
3
|
+
import { C as Cart } from './orders-ZKP0lqRN.cjs';
|
|
3
4
|
|
|
4
5
|
/** The fields we keep from Google's payload — the rest would only bloat localStorage. */
|
|
5
6
|
type RawAddressData = {
|
|
@@ -176,4 +177,44 @@ declare function findSubdivision(states: CountryModel.State1[], match: PincodeMa
|
|
|
176
177
|
/** Distinct locality names inside the district, when the pincode covers more than one. */
|
|
177
178
|
declare function getAreaOptions(match: PincodeMatch | null): string[];
|
|
178
179
|
|
|
179
|
-
|
|
180
|
+
/**
|
|
181
|
+
* A customization input's price. The cart sends `effective_price` (what the
|
|
182
|
+
* backend charged) next to `customization_price`; other endpoints send only
|
|
183
|
+
* `additional_price` or `customization_price`.
|
|
184
|
+
*/
|
|
185
|
+
declare function getCustomizationPrice(input: Cart.CustomizationInput | null | undefined): number;
|
|
186
|
+
/** Anything cart-shaped: the server cart, `LocalCart`, a buy-now or public preview. */
|
|
187
|
+
type CartLike = Pick<Cart.Root, "product_variants" | "products_quantity" | "customization_inputs"> | null | undefined;
|
|
188
|
+
interface CheckoutTotals {
|
|
189
|
+
/** Pre-discount line total: `actual_price` where one is set, else `selling_price`, × quantity. */
|
|
190
|
+
subtotal: number;
|
|
191
|
+
/** (`actual_price` − `selling_price`) × quantity, summed across the lines. */
|
|
192
|
+
discountAmount: number;
|
|
193
|
+
/** Tax already inside the prices (`total_tax_price` is a line total). */
|
|
194
|
+
totalInclusiveTax: number;
|
|
195
|
+
/** Tax added on top of the prices. */
|
|
196
|
+
totalExclusiveTax: number;
|
|
197
|
+
/** Customization charges for the whole cart: each line's per-unit charge × its quantity. */
|
|
198
|
+
totalCustomizationPrice: number;
|
|
199
|
+
/** Per-unit customization charge of each variant, keyed by variant id. */
|
|
200
|
+
customizationTotalsByVariant: Record<number, number>;
|
|
201
|
+
/** Customization inputs grouped by the variant they belong to. */
|
|
202
|
+
groupedCustomizeInputs: Record<number, Cart.CustomizationInput[]>;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The line-level money maths every checkout shows. The cart, buy-now and public
|
|
206
|
+
* one-time payloads are key-compatible, so all three use this.
|
|
207
|
+
*
|
|
208
|
+
* Shipping, coupon discount, tax total and the grand total are deliberately NOT
|
|
209
|
+
* derived here: read them off the payload (`total_shipping`,
|
|
210
|
+
* `total_coupon_discount`, `total_tax_amount`, `total_amount`). The backend is
|
|
211
|
+
* the only thing allowed to decide what the customer is charged.
|
|
212
|
+
*
|
|
213
|
+
* @param cart The cart / preview payload being rendered.
|
|
214
|
+
* @param customizationOverride Inputs to price instead of the cart's own: an
|
|
215
|
+
* already-placed order carries its own copy, which
|
|
216
|
+
* is the authoritative one.
|
|
217
|
+
*/
|
|
218
|
+
declare function calculateCartTotals(cart: CartLike, customizationOverride?: Cart.CustomizationInput[] | null): CheckoutTotals;
|
|
219
|
+
|
|
220
|
+
export { type AddressFormat as A, type CartLike as C, DEFAULT_ADDRESS_SCHEMA_MESSAGES as D, INVALID_PINCODE as I, NO_POSTAL_CODE as N, PINCODE_DEBOUNCE_MS as P, type RawAddressData as R, type AddressSchemaMessages as a, type CheckoutTotals as b, PINCODE_MIN_LENGTH as c, PINCODE_VALIDATION_UNAVAILABLE as d, type PincodeCheck as e, type PincodeMatch as f, buildAddressFormat as g, buildAddressSchema as h, calculateCartTotals as i, clearPincodeCache as j, findStateByName as k, findSubdivision as l, getAreaOptions as m, getCustomizationPrice as n, getPincodeError as o, getPostcodeHint as p, joinAddressLines as q, loadAddressFormat as r, lowerLabel as s, normalizePostcode as t, sanitizePincode as u, usableEmail as v, validatePincode as w };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as Yup from 'yup';
|
|
2
2
|
import { P as Pincode } from './pincode-8u7yWLpQ.js';
|
|
3
|
+
import { C as Cart } from './orders-B6BmHCJN.js';
|
|
3
4
|
|
|
4
5
|
/** The fields we keep from Google's payload — the rest would only bloat localStorage. */
|
|
5
6
|
type RawAddressData = {
|
|
@@ -176,4 +177,44 @@ declare function findSubdivision(states: CountryModel.State1[], match: PincodeMa
|
|
|
176
177
|
/** Distinct locality names inside the district, when the pincode covers more than one. */
|
|
177
178
|
declare function getAreaOptions(match: PincodeMatch | null): string[];
|
|
178
179
|
|
|
179
|
-
|
|
180
|
+
/**
|
|
181
|
+
* A customization input's price. The cart sends `effective_price` (what the
|
|
182
|
+
* backend charged) next to `customization_price`; other endpoints send only
|
|
183
|
+
* `additional_price` or `customization_price`.
|
|
184
|
+
*/
|
|
185
|
+
declare function getCustomizationPrice(input: Cart.CustomizationInput | null | undefined): number;
|
|
186
|
+
/** Anything cart-shaped: the server cart, `LocalCart`, a buy-now or public preview. */
|
|
187
|
+
type CartLike = Pick<Cart.Root, "product_variants" | "products_quantity" | "customization_inputs"> | null | undefined;
|
|
188
|
+
interface CheckoutTotals {
|
|
189
|
+
/** Pre-discount line total: `actual_price` where one is set, else `selling_price`, × quantity. */
|
|
190
|
+
subtotal: number;
|
|
191
|
+
/** (`actual_price` − `selling_price`) × quantity, summed across the lines. */
|
|
192
|
+
discountAmount: number;
|
|
193
|
+
/** Tax already inside the prices (`total_tax_price` is a line total). */
|
|
194
|
+
totalInclusiveTax: number;
|
|
195
|
+
/** Tax added on top of the prices. */
|
|
196
|
+
totalExclusiveTax: number;
|
|
197
|
+
/** Customization charges for the whole cart: each line's per-unit charge × its quantity. */
|
|
198
|
+
totalCustomizationPrice: number;
|
|
199
|
+
/** Per-unit customization charge of each variant, keyed by variant id. */
|
|
200
|
+
customizationTotalsByVariant: Record<number, number>;
|
|
201
|
+
/** Customization inputs grouped by the variant they belong to. */
|
|
202
|
+
groupedCustomizeInputs: Record<number, Cart.CustomizationInput[]>;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The line-level money maths every checkout shows. The cart, buy-now and public
|
|
206
|
+
* one-time payloads are key-compatible, so all three use this.
|
|
207
|
+
*
|
|
208
|
+
* Shipping, coupon discount, tax total and the grand total are deliberately NOT
|
|
209
|
+
* derived here: read them off the payload (`total_shipping`,
|
|
210
|
+
* `total_coupon_discount`, `total_tax_amount`, `total_amount`). The backend is
|
|
211
|
+
* the only thing allowed to decide what the customer is charged.
|
|
212
|
+
*
|
|
213
|
+
* @param cart The cart / preview payload being rendered.
|
|
214
|
+
* @param customizationOverride Inputs to price instead of the cart's own: an
|
|
215
|
+
* already-placed order carries its own copy, which
|
|
216
|
+
* is the authoritative one.
|
|
217
|
+
*/
|
|
218
|
+
declare function calculateCartTotals(cart: CartLike, customizationOverride?: Cart.CustomizationInput[] | null): CheckoutTotals;
|
|
219
|
+
|
|
220
|
+
export { type AddressFormat as A, type CartLike as C, DEFAULT_ADDRESS_SCHEMA_MESSAGES as D, INVALID_PINCODE as I, NO_POSTAL_CODE as N, PINCODE_DEBOUNCE_MS as P, type RawAddressData as R, type AddressSchemaMessages as a, type CheckoutTotals as b, PINCODE_MIN_LENGTH as c, PINCODE_VALIDATION_UNAVAILABLE as d, type PincodeCheck as e, type PincodeMatch as f, buildAddressFormat as g, buildAddressSchema as h, calculateCartTotals as i, clearPincodeCache as j, findStateByName as k, findSubdivision as l, getAreaOptions as m, getCustomizationPrice as n, getPincodeError as o, getPostcodeHint as p, joinAddressLines as q, loadAddressFormat as r, lowerLabel as s, normalizePostcode as t, sanitizePincode as u, usableEmail as v, validatePincode as w };
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
var chunkNE3ZHELZ_cjs = require('./chunk-NE3ZHELZ.cjs');
|
|
4
4
|
|
|
5
5
|
// src/utils/cart.ts
|
|
6
|
+
function remainingStock(product, inCart) {
|
|
7
|
+
const stock = Number(product?.stock_quantity);
|
|
8
|
+
if (product?.stock_quantity == null || Number.isNaN(stock)) return null;
|
|
9
|
+
return Math.max(stock - inCart, 0);
|
|
10
|
+
}
|
|
6
11
|
var LocalCart = {
|
|
7
12
|
get() {
|
|
8
13
|
const storeData = localStorage.getItem(chunkNE3ZHELZ_cjs.USER_CART);
|
|
@@ -11,9 +16,21 @@ var LocalCart = {
|
|
|
11
16
|
set(cart) {
|
|
12
17
|
localStorage.setItem(chunkNE3ZHELZ_cjs.USER_CART, JSON.stringify(cart));
|
|
13
18
|
},
|
|
19
|
+
/**
|
|
20
|
+
* Adds `quantity` of `product`, capped so the line never goes past the
|
|
21
|
+
* product's stock: the guest cart isn't checked against the server until
|
|
22
|
+
* checkout, so repeated adds would otherwise pile up past what's available.
|
|
23
|
+
* Returns how many units were actually added (0 when at the limit or for a
|
|
24
|
+
* pre-order); compare it with the requested quantity to tell the shopper.
|
|
25
|
+
*/
|
|
14
26
|
add(product, quantity = 1) {
|
|
15
|
-
|
|
27
|
+
if (product?.is_preorder) return 0;
|
|
28
|
+
const requested = Number(quantity) || 1;
|
|
16
29
|
const cart = this.get();
|
|
30
|
+
const inCart = Number(cart?.products_quantity?.[product.id]) || 0;
|
|
31
|
+
const remaining = remainingStock(product, inCart);
|
|
32
|
+
const qty = remaining === null ? requested : Math.min(requested, remaining);
|
|
33
|
+
if (qty <= 0) return 0;
|
|
17
34
|
if (!cart) {
|
|
18
35
|
this.set({
|
|
19
36
|
product_variants: [product],
|
|
@@ -23,31 +40,22 @@ var LocalCart = {
|
|
|
23
40
|
total_amount: Number(product.selling_price) * qty,
|
|
24
41
|
variant_discounts: {}
|
|
25
42
|
});
|
|
26
|
-
return;
|
|
43
|
+
return qty;
|
|
27
44
|
}
|
|
28
45
|
const newCart = cart.product_variants || [];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
cart.
|
|
32
|
-
...cart.products_quantity,
|
|
33
|
-
[product.id]: (Number(cart.products_quantity[product.id]) || 0) + qty
|
|
34
|
-
};
|
|
35
|
-
cart.total_quantity = Number(cart.total_quantity) + qty;
|
|
36
|
-
cart.cart_count = Number(cart.cart_count) + qty;
|
|
37
|
-
cart.total_amount = Number(cart.total_amount) + Number(product.selling_price) * qty;
|
|
38
|
-
this.set(cart);
|
|
39
|
-
return;
|
|
46
|
+
if (!newCart.some((prod) => prod.id === product.id)) {
|
|
47
|
+
newCart.push(product);
|
|
48
|
+
cart.product_variants = newCart;
|
|
40
49
|
}
|
|
41
|
-
newCart.push(product);
|
|
42
50
|
cart.products_quantity = {
|
|
43
51
|
...cart.products_quantity,
|
|
44
|
-
[product.id]:
|
|
52
|
+
[product.id]: inCart + qty
|
|
45
53
|
};
|
|
46
|
-
cart.product_variants = newCart;
|
|
47
54
|
cart.total_quantity = Number(cart.total_quantity) + qty;
|
|
48
55
|
cart.cart_count = Number(cart.cart_count) + qty;
|
|
49
56
|
cart.total_amount = Number(cart.total_amount) + Number(product.selling_price) * qty;
|
|
50
57
|
this.set(cart);
|
|
58
|
+
return qty;
|
|
51
59
|
},
|
|
52
60
|
remove(product) {
|
|
53
61
|
const cart = this.get();
|
|
@@ -79,7 +79,7 @@ async function handleRazorpaySuccess(data, order, callbacks, options) {
|
|
|
79
79
|
try {
|
|
80
80
|
callbacks.onPaymentStart?.();
|
|
81
81
|
if (options?.isPublic) {
|
|
82
|
-
await razorpayPublicOrderSuccess(data);
|
|
82
|
+
await razorpayPublicOrderSuccess({ ...data, order_number: order.order_number });
|
|
83
83
|
} else {
|
|
84
84
|
await razorpayOrderSuccess(data);
|
|
85
85
|
}
|
|
@@ -542,4 +542,60 @@ function getAreaOptions(match) {
|
|
|
542
542
|
return unique.length > 1 ? unique : NO_AREAS;
|
|
543
543
|
}
|
|
544
544
|
|
|
545
|
-
|
|
545
|
+
// src/checkout/checkout-totals.ts
|
|
546
|
+
function getCustomizationPrice(input) {
|
|
547
|
+
return Number(
|
|
548
|
+
input?.effective_price ?? input?.additional_price ?? input?.customization_price ?? 0
|
|
549
|
+
) || 0;
|
|
550
|
+
}
|
|
551
|
+
function calculateCartTotals(cart, customizationOverride) {
|
|
552
|
+
var _a;
|
|
553
|
+
const variants = cart?.product_variants || [];
|
|
554
|
+
const quantityOf = (variantId) => {
|
|
555
|
+
const line = variants.find((item) => item.id === variantId);
|
|
556
|
+
return Number(line?.quantity) || Number(cart?.products_quantity?.[variantId]) || 0;
|
|
557
|
+
};
|
|
558
|
+
let subtotal = 0;
|
|
559
|
+
let discountAmount = 0;
|
|
560
|
+
let totalInclusiveTax = 0;
|
|
561
|
+
let totalExclusiveTax = 0;
|
|
562
|
+
for (const item of variants) {
|
|
563
|
+
const quantity = quantityOf(item.id);
|
|
564
|
+
const actualPrice = Number(item.actual_price);
|
|
565
|
+
const sellingPrice = Number(item.selling_price);
|
|
566
|
+
if (actualPrice > 0) {
|
|
567
|
+
subtotal += actualPrice * quantity;
|
|
568
|
+
discountAmount += (actualPrice - sellingPrice) * quantity;
|
|
569
|
+
} else {
|
|
570
|
+
subtotal += sellingPrice * quantity;
|
|
571
|
+
}
|
|
572
|
+
const tax = Number(item.total_tax_price) || 0;
|
|
573
|
+
if (item.is_tax_inclusive_price) totalInclusiveTax += tax;
|
|
574
|
+
else totalExclusiveTax += tax;
|
|
575
|
+
}
|
|
576
|
+
const groupedCustomizeInputs = {};
|
|
577
|
+
for (const input of cart?.customization_inputs || []) {
|
|
578
|
+
(groupedCustomizeInputs[_a = input.product_variant] || (groupedCustomizeInputs[_a] = [])).push(input);
|
|
579
|
+
}
|
|
580
|
+
const customizationTotalsByVariant = {};
|
|
581
|
+
for (const input of customizationOverride || cart?.customization_inputs || []) {
|
|
582
|
+
customizationTotalsByVariant[input.product_variant] = (customizationTotalsByVariant[input.product_variant] || 0) + getCustomizationPrice(input);
|
|
583
|
+
}
|
|
584
|
+
const totalCustomizationPrice = Object.entries(
|
|
585
|
+
customizationTotalsByVariant
|
|
586
|
+
).reduce(
|
|
587
|
+
(acc, [variantId, perUnit]) => acc + perUnit * quantityOf(Number(variantId)),
|
|
588
|
+
0
|
|
589
|
+
);
|
|
590
|
+
return {
|
|
591
|
+
subtotal,
|
|
592
|
+
discountAmount,
|
|
593
|
+
totalInclusiveTax,
|
|
594
|
+
totalExclusiveTax,
|
|
595
|
+
totalCustomizationPrice,
|
|
596
|
+
customizationTotalsByVariant,
|
|
597
|
+
groupedCustomizeInputs
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
export { DEFAULT_ADDRESS_SCHEMA_MESSAGES, INVALID_PINCODE, NO_POSTAL_CODE, PINCODE_DEBOUNCE_MS, PINCODE_MIN_LENGTH, PINCODE_VALIDATION_UNAVAILABLE, applyCheckoutCoupon, buildAddressFormat, buildAddressSchema, calculateCartTotals, clearPincodeCache, detectForeignPhone, fetchAppliedCoupon, fetchAvailableCoupons, findStateByName, findSubdivision, getAreaOptions, getCustomizationPrice, getPincodeError, getPostcodeHint, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, isValidNumber, joinAddressLines, loadAddressFormat, lowerLabel, normalizePostcode, openRazorpayCheckout, processPayment, removeCheckoutCoupon, sanitizePhoneInput, sanitizePincode, usableEmail, validatePincode };
|