@merchi/cart 1.4.62 → 1.4.64
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/esm/CartProvider.js +316 -243
- package/esm/CartProvider.load.test.js +957 -95
- package/esm/utilities/automatedClient.js +5 -0
- package/esm/utilities/automatedClient.test.js +9 -0
- package/lib/CartProvider.js +317 -244
- package/lib/utilities/automatedClient.d.ts +2 -0
- package/lib/utilities/automatedClient.js +11 -0
- package/lib/utilities/automatedClient.test.d.ts +1 -0
- package/package.json +1 -1
- package/src/CartProvider.load.test.tsx +252 -2
- package/src/CartProvider.tsx +66 -32
- package/src/utilities/automatedClient.test.ts +21 -0
- package/src/utilities/automatedClient.ts +6 -0
package/esm/CartProvider.js
CHANGED
|
@@ -34,6 +34,7 @@ import { getSavedCheckoutCustomer, saveCheckoutAddress } from './utilities/local
|
|
|
34
34
|
import { makeUser } from './utilities/user';
|
|
35
35
|
import { persistTestCheckoutFlag, readTestCheckoutFlag } from './utilities/test_checkout';
|
|
36
36
|
import { reportAddCartItemFailure, reportCartFailure, CART_FAILURE_SOURCES } from './utilities/reportFailure';
|
|
37
|
+
import { isAutomatedClient } from './utilities/automatedClient';
|
|
37
38
|
import { canReplaceMissingCart } from './utilities/cartLoadFailure';
|
|
38
39
|
import { appendJobSourceToFormData, captureAndReadJobSource, cartNeedsSourceUpdate, jobSourceFieldsForApi } from './utilities/job_source';
|
|
39
40
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -428,72 +429,73 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
428
429
|
cartSettingsInvalid = _useState16[0],
|
|
429
430
|
setCartSettingsInvalid = _useState16[1];
|
|
430
431
|
var appliedHandoffCart = useRef(null);
|
|
432
|
+
var cartInitializations = useRef(new Map());
|
|
431
433
|
function attachSavedClientIfNeeded(_x) {
|
|
432
434
|
return _attachSavedClientIfNeeded.apply(this, arguments);
|
|
433
435
|
} // Create cart and save cart cookie
|
|
434
436
|
function _attachSavedClientIfNeeded() {
|
|
435
|
-
_attachSavedClientIfNeeded = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
437
|
+
_attachSavedClientIfNeeded = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(cartJson) {
|
|
436
438
|
var _cartJson$client;
|
|
437
|
-
var savedCustomer, _nextCart$client, cartToken, clientEnt, cartEnt, savedCart, nextCart,
|
|
438
|
-
return _regenerator().w(function (
|
|
439
|
-
while (1) switch (
|
|
439
|
+
var savedCustomer, _nextCart$client, cartToken, clientEnt, cartEnt, savedCart, nextCart, _t3, _t4;
|
|
440
|
+
return _regenerator().w(function (_context3) {
|
|
441
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
440
442
|
case 0:
|
|
441
443
|
if (!(cartJson !== null && cartJson !== void 0 && (_cartJson$client = cartJson.client) !== null && _cartJson$client !== void 0 && _cartJson$client.id)) {
|
|
442
|
-
|
|
444
|
+
_context3.n = 1;
|
|
443
445
|
break;
|
|
444
446
|
}
|
|
445
447
|
setCartClient(cartJson.client);
|
|
446
|
-
return
|
|
448
|
+
return _context3.a(2, cartJson);
|
|
447
449
|
case 1:
|
|
448
450
|
savedCustomer = getSavedCheckoutCustomer(domainId);
|
|
449
451
|
if (savedCustomer !== null && savedCustomer !== void 0 && savedCustomer.id) {
|
|
450
|
-
|
|
452
|
+
_context3.n = 2;
|
|
451
453
|
break;
|
|
452
454
|
}
|
|
453
455
|
setCartClient(null);
|
|
454
|
-
return
|
|
456
|
+
return _context3.a(2, cartJson);
|
|
455
457
|
case 2:
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
if (
|
|
459
|
-
|
|
458
|
+
_context3.p = 2;
|
|
459
|
+
_t3 = cartJson.token;
|
|
460
|
+
if (_t3) {
|
|
461
|
+
_context3.n = 4;
|
|
460
462
|
break;
|
|
461
463
|
}
|
|
462
|
-
|
|
464
|
+
_context3.n = 3;
|
|
463
465
|
return getCartCookieToken(domainId);
|
|
464
466
|
case 3:
|
|
465
|
-
|
|
467
|
+
_t3 = _context3.v;
|
|
466
468
|
case 4:
|
|
467
|
-
cartToken =
|
|
469
|
+
cartToken = _t3;
|
|
468
470
|
clientEnt = makeUser({
|
|
469
471
|
id: savedCustomer.id
|
|
470
472
|
}, true);
|
|
471
473
|
cartEnt = makeCart(_objectSpread({}, cartJson), false, cartToken);
|
|
472
474
|
cartEnt.client = clientEnt;
|
|
473
|
-
|
|
475
|
+
_context3.n = 5;
|
|
474
476
|
return cartEnt.save({
|
|
475
477
|
embed: cartEmbed
|
|
476
478
|
});
|
|
477
479
|
case 5:
|
|
478
|
-
savedCart =
|
|
480
|
+
savedCart = _context3.v;
|
|
479
481
|
nextCart = savedCart.toJson();
|
|
480
482
|
if (!(nextCart !== null && nextCart !== void 0 && (_nextCart$client = nextCart.client) !== null && _nextCart$client !== void 0 && _nextCart$client.id)) {
|
|
481
|
-
|
|
483
|
+
_context3.n = 6;
|
|
482
484
|
break;
|
|
483
485
|
}
|
|
484
486
|
setCartClient(nextCart.client);
|
|
485
|
-
return
|
|
487
|
+
return _context3.a(2, nextCart);
|
|
486
488
|
case 6:
|
|
487
|
-
|
|
489
|
+
_context3.n = 8;
|
|
488
490
|
break;
|
|
489
491
|
case 7:
|
|
490
|
-
|
|
491
|
-
|
|
492
|
+
_context3.p = 7;
|
|
493
|
+
_t4 = _context3.v;
|
|
492
494
|
case 8:
|
|
493
495
|
setCartClient(null);
|
|
494
|
-
return
|
|
496
|
+
return _context3.a(2, cartJson);
|
|
495
497
|
}
|
|
496
|
-
},
|
|
498
|
+
}, _callee3, null, [[2, 7]]);
|
|
497
499
|
}));
|
|
498
500
|
return _attachSavedClientIfNeeded.apply(this, arguments);
|
|
499
501
|
}
|
|
@@ -501,13 +503,13 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
501
503
|
return _createCartAndCookie.apply(this, arguments);
|
|
502
504
|
}
|
|
503
505
|
function _createCartAndCookie() {
|
|
504
|
-
_createCartAndCookie = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
505
|
-
var isTest, jobSource, _cart, query, created, cartJson,
|
|
506
|
-
return _regenerator().w(function (
|
|
507
|
-
while (1) switch (
|
|
506
|
+
_createCartAndCookie = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(callback) {
|
|
507
|
+
var isTest, jobSource, _cart, query, created, cartJson, _t5;
|
|
508
|
+
return _regenerator().w(function (_context4) {
|
|
509
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
508
510
|
case 0:
|
|
509
511
|
setFetchingCart(true);
|
|
510
|
-
|
|
512
|
+
_context4.p = 1;
|
|
511
513
|
isTest = readTestCheckoutFlag();
|
|
512
514
|
jobSource = jobSourceFieldsForApi(captureAndReadJobSource());
|
|
513
515
|
_cart = makeCart({
|
|
@@ -518,136 +520,150 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
518
520
|
}, true);
|
|
519
521
|
query = [['embed', JSON.stringify(cartEmbed)], ['skip_rights', 'y']];
|
|
520
522
|
if (isTest) query.push(['is_test', 'true']);
|
|
521
|
-
|
|
523
|
+
_context4.n = 2;
|
|
522
524
|
return merchi.authenticatedFetch('/carts/', {
|
|
523
525
|
method: 'POST',
|
|
524
526
|
body: appendJobSourceToFormData(_cart.toFormData(), jobSource),
|
|
525
527
|
query: query
|
|
526
528
|
});
|
|
527
529
|
case 2:
|
|
528
|
-
created =
|
|
530
|
+
created = _context4.v;
|
|
529
531
|
_cart.fromJson(created.cart);
|
|
530
|
-
|
|
532
|
+
_context4.n = 3;
|
|
531
533
|
return _cart.toJson();
|
|
532
534
|
case 3:
|
|
533
|
-
cartJson =
|
|
535
|
+
cartJson = _context4.v;
|
|
534
536
|
if (domainId) setCartCookie(Number(domainId), cartJson, undefined, isTest);
|
|
535
|
-
|
|
537
|
+
_context4.n = 4;
|
|
536
538
|
return attachSavedClientIfNeeded(cartJson);
|
|
537
539
|
case 4:
|
|
538
|
-
cartJson =
|
|
540
|
+
cartJson = _context4.v;
|
|
539
541
|
setCart(_objectSpread({}, cartJson));
|
|
540
542
|
if (callback) callback();
|
|
541
|
-
|
|
542
|
-
break;
|
|
543
|
+
return _context4.a(2, cartJson);
|
|
543
544
|
case 5:
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
reportCartFailure(
|
|
547
|
-
alertError((
|
|
545
|
+
_context4.p = 5;
|
|
546
|
+
_t5 = _context4.v;
|
|
547
|
+
reportCartFailure(_t5, CART_FAILURE_SOURCES.create);
|
|
548
|
+
alertError((_t5 === null || _t5 === void 0 ? void 0 : _t5.errorMessage) || (_t5 === null || _t5 === void 0 ? void 0 : _t5.message) || 'Unable to fetch cart.');
|
|
548
549
|
case 6:
|
|
549
|
-
|
|
550
|
+
_context4.p = 6;
|
|
550
551
|
setFetchingCart(false);
|
|
551
|
-
return
|
|
552
|
+
return _context4.f(6);
|
|
552
553
|
case 7:
|
|
553
|
-
return
|
|
554
|
+
return _context4.a(2, undefined);
|
|
554
555
|
}
|
|
555
|
-
},
|
|
556
|
+
}, _callee4, null, [[1, 5, 6, 7]]);
|
|
556
557
|
}));
|
|
557
558
|
return _createCartAndCookie.apply(this, arguments);
|
|
558
559
|
}
|
|
559
|
-
function
|
|
560
|
+
function requestNewCart(_x3) {
|
|
561
|
+
return _requestNewCart.apply(this, arguments);
|
|
562
|
+
}
|
|
563
|
+
function _requestNewCart() {
|
|
564
|
+
_requestNewCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(callback) {
|
|
565
|
+
return _regenerator().w(function (_context5) {
|
|
566
|
+
while (1) switch (_context5.n) {
|
|
567
|
+
case 0:
|
|
568
|
+
_context5.n = 1;
|
|
569
|
+
return createCartAndCookie(callback);
|
|
570
|
+
case 1:
|
|
571
|
+
return _context5.a(2);
|
|
572
|
+
}
|
|
573
|
+
}, _callee5);
|
|
574
|
+
}));
|
|
575
|
+
return _requestNewCart.apply(this, arguments);
|
|
576
|
+
}
|
|
577
|
+
function getCart(_x4) {
|
|
560
578
|
return _getCart.apply(this, arguments);
|
|
561
579
|
} // A checkout link can name the cart. Remember it once, then keep using the cookie
|
|
562
580
|
// so a later refetch does not put that cart back after the shopper replaced it.
|
|
563
581
|
function _getCart() {
|
|
564
|
-
_getCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
565
|
-
var id, _cart2, cartJson, isTest, jobSource, saved,
|
|
566
|
-
return _regenerator().w(function (
|
|
567
|
-
while (1) switch (
|
|
582
|
+
_getCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(cartIdAndToken) {
|
|
583
|
+
var id, _cart2, cartJson, isTest, jobSource, saved, _t6;
|
|
584
|
+
return _regenerator().w(function (_context6) {
|
|
585
|
+
while (1) switch (_context6.p = _context6.n) {
|
|
568
586
|
case 0:
|
|
569
587
|
id = Number(cartIdAndToken[0]); // Set the cart token on the merchi entity
|
|
570
588
|
if (cartIdAndToken[1]) merchi.cartToken = cartIdAndToken[1];
|
|
571
589
|
setFetchingCart(true);
|
|
572
|
-
|
|
573
|
-
|
|
590
|
+
_context6.p = 1;
|
|
591
|
+
_context6.n = 2;
|
|
574
592
|
return merchi.Cart.get(id, {
|
|
575
593
|
embed: cartEmbed
|
|
576
594
|
});
|
|
577
595
|
case 2:
|
|
578
|
-
_cart2 =
|
|
579
|
-
|
|
596
|
+
_cart2 = _context6.v;
|
|
597
|
+
_context6.n = 3;
|
|
580
598
|
return _cart2.toJson();
|
|
581
599
|
case 3:
|
|
582
|
-
cartJson =
|
|
600
|
+
cartJson = _context6.v;
|
|
583
601
|
isTest = readTestCheckoutFlag();
|
|
584
602
|
if (!(Boolean(cartJson.isTest) !== isTest)) {
|
|
585
|
-
|
|
603
|
+
_context6.n = 5;
|
|
586
604
|
break;
|
|
587
605
|
}
|
|
588
|
-
|
|
606
|
+
_context6.n = 4;
|
|
589
607
|
return createCartAndCookie();
|
|
590
608
|
case 4:
|
|
591
|
-
return
|
|
609
|
+
return _context6.a(2, _context6.v);
|
|
592
610
|
case 5:
|
|
593
611
|
jobSource = jobSourceFieldsForApi(captureAndReadJobSource());
|
|
594
612
|
if (!cartNeedsSourceUpdate(cartJson, jobSource)) {
|
|
595
|
-
|
|
613
|
+
_context6.n = 7;
|
|
596
614
|
break;
|
|
597
615
|
}
|
|
598
|
-
|
|
616
|
+
_context6.n = 6;
|
|
599
617
|
return merchi.authenticatedFetch("/carts/".concat(_cart2.id, "/"), {
|
|
600
618
|
method: 'PATCH',
|
|
601
619
|
body: appendJobSourceToFormData(_cart2.toFormData(), jobSource),
|
|
602
620
|
query: [['embed', JSON.stringify(cartEmbed)], ['skip_rights', 'y']]
|
|
603
621
|
});
|
|
604
622
|
case 6:
|
|
605
|
-
saved =
|
|
623
|
+
saved = _context6.v;
|
|
606
624
|
_cart2.fromJson(saved.cart);
|
|
607
625
|
cartJson = _cart2.toJson();
|
|
608
626
|
case 7:
|
|
609
627
|
if (!(stripeIsValidAndActive(cartJson) || isTest)) {
|
|
610
|
-
|
|
628
|
+
_context6.n = 9;
|
|
611
629
|
break;
|
|
612
630
|
}
|
|
613
|
-
|
|
631
|
+
_context6.n = 8;
|
|
614
632
|
return attachSavedClientIfNeeded(cartJson);
|
|
615
633
|
case 8:
|
|
616
|
-
cartJson =
|
|
634
|
+
cartJson = _context6.v;
|
|
617
635
|
setCart(_objectSpread({}, cartJson));
|
|
618
|
-
|
|
619
|
-
break;
|
|
636
|
+
return _context6.a(2, cartJson);
|
|
620
637
|
case 9:
|
|
621
638
|
console.error("MErhci cart error: Stripe payment " + "options have not been correctly set up. " + "Check the company profile payment options tab " + "to set and edit stripe payment options.");
|
|
622
639
|
setCartSettingsInvalid(true);
|
|
623
640
|
case 10:
|
|
624
|
-
|
|
641
|
+
_context6.n = 14;
|
|
625
642
|
break;
|
|
626
643
|
case 11:
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
if (!canReplaceMissingCart(
|
|
630
|
-
|
|
644
|
+
_context6.p = 11;
|
|
645
|
+
_t6 = _context6.v;
|
|
646
|
+
if (!canReplaceMissingCart(_t6)) {
|
|
647
|
+
_context6.n = 13;
|
|
631
648
|
break;
|
|
632
649
|
}
|
|
633
|
-
|
|
650
|
+
_context6.n = 12;
|
|
634
651
|
return createCartAndCookie();
|
|
635
652
|
case 12:
|
|
636
|
-
|
|
637
|
-
break;
|
|
653
|
+
return _context6.a(2, _context6.v);
|
|
638
654
|
case 13:
|
|
639
655
|
// A network/server/auth failure does not mean the saved cart is gone.
|
|
640
656
|
// Preserve its cookie and contents so the shopper can retry the read.
|
|
641
|
-
reportCartFailure(
|
|
642
|
-
alertError((
|
|
657
|
+
reportCartFailure(_t6, CART_FAILURE_SOURCES.load);
|
|
658
|
+
alertError((_t6 === null || _t6 === void 0 ? void 0 : _t6.errorMessage) || (_t6 === null || _t6 === void 0 ? void 0 : _t6.message) || 'Unable to load cart. Please try again.');
|
|
643
659
|
case 14:
|
|
644
|
-
|
|
660
|
+
_context6.p = 14;
|
|
645
661
|
setFetchingCart(false);
|
|
646
|
-
return
|
|
662
|
+
return _context6.f(14);
|
|
647
663
|
case 15:
|
|
648
|
-
return
|
|
664
|
+
return _context6.a(2, undefined);
|
|
649
665
|
}
|
|
650
|
-
},
|
|
666
|
+
}, _callee6, null, [[1, 11, 14, 15]]);
|
|
651
667
|
}));
|
|
652
668
|
return _getCart.apply(this, arguments);
|
|
653
669
|
}
|
|
@@ -655,88 +671,115 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
655
671
|
return _adoptHandoffCart.apply(this, arguments);
|
|
656
672
|
}
|
|
657
673
|
function _adoptHandoffCart() {
|
|
658
|
-
_adoptHandoffCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
674
|
+
_adoptHandoffCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
659
675
|
var raw, handoff;
|
|
660
|
-
return _regenerator().w(function (
|
|
661
|
-
while (1) switch (
|
|
676
|
+
return _regenerator().w(function (_context7) {
|
|
677
|
+
while (1) switch (_context7.n) {
|
|
662
678
|
case 0:
|
|
663
679
|
if (!(typeof window === 'undefined' || !domainId)) {
|
|
664
|
-
|
|
680
|
+
_context7.n = 1;
|
|
665
681
|
break;
|
|
666
682
|
}
|
|
667
|
-
return
|
|
683
|
+
return _context7.a(2);
|
|
668
684
|
case 1:
|
|
669
685
|
raw = new URLSearchParams(window.location.search).get('cart');
|
|
670
686
|
if (!(!raw || raw === appliedHandoffCart.current)) {
|
|
671
|
-
|
|
687
|
+
_context7.n = 2;
|
|
672
688
|
break;
|
|
673
689
|
}
|
|
674
|
-
return
|
|
690
|
+
return _context7.a(2);
|
|
675
691
|
case 2:
|
|
676
692
|
handoff = readHandoffCart(window.location.search);
|
|
677
693
|
if (handoff) {
|
|
678
|
-
|
|
694
|
+
_context7.n = 3;
|
|
679
695
|
break;
|
|
680
696
|
}
|
|
681
|
-
return
|
|
697
|
+
return _context7.a(2);
|
|
682
698
|
case 3:
|
|
683
699
|
appliedHandoffCart.current = raw;
|
|
684
|
-
|
|
700
|
+
_context7.n = 4;
|
|
685
701
|
return setCartCookie(Number(domainId), {
|
|
686
702
|
id: handoff[0],
|
|
687
703
|
token: handoff[1]
|
|
688
704
|
});
|
|
689
705
|
case 4:
|
|
690
|
-
return
|
|
706
|
+
return _context7.a(2);
|
|
691
707
|
}
|
|
692
|
-
},
|
|
708
|
+
}, _callee7);
|
|
693
709
|
}));
|
|
694
710
|
return _adoptHandoffCart.apply(this, arguments);
|
|
695
711
|
}
|
|
696
712
|
function actionGetMerchiCart() {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
713
|
+
var allowCreation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
714
|
+
var active = cartInitializations.current.get(domainId);
|
|
715
|
+
// Mount, modal opening and explicit callers may run before React commits
|
|
716
|
+
// fetchingCart. Share the whole cookie lookup/read-or-create operation.
|
|
717
|
+
if (!active) {
|
|
718
|
+
active = Promise.resolve().then(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
719
|
+
var cartIdAndToken, _t, _t2;
|
|
720
|
+
return _regenerator().w(function (_context) {
|
|
721
|
+
while (1) switch (_context.n) {
|
|
722
|
+
case 0:
|
|
723
|
+
_context.n = 1;
|
|
724
|
+
return adoptHandoffCart();
|
|
725
|
+
case 1:
|
|
726
|
+
_context.n = 2;
|
|
727
|
+
return getCartCookie(domainId);
|
|
728
|
+
case 2:
|
|
729
|
+
cartIdAndToken = _context.v;
|
|
730
|
+
if (!cartIdAndToken) {
|
|
731
|
+
_context.n = 4;
|
|
732
|
+
break;
|
|
733
|
+
}
|
|
734
|
+
_context.n = 3;
|
|
735
|
+
return getCart(cartIdAndToken);
|
|
736
|
+
case 3:
|
|
737
|
+
_t = _context.v;
|
|
738
|
+
return _context.a(2, {
|
|
739
|
+
skippedCreation: false,
|
|
740
|
+
cart: _t
|
|
741
|
+
});
|
|
742
|
+
case 4:
|
|
743
|
+
if (!allowCreation) {
|
|
744
|
+
_context.n = 6;
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
_context.n = 5;
|
|
748
|
+
return createCartAndCookie();
|
|
749
|
+
case 5:
|
|
750
|
+
_t2 = _context.v;
|
|
751
|
+
return _context.a(2, {
|
|
752
|
+
skippedCreation: false,
|
|
753
|
+
cart: _t2
|
|
754
|
+
});
|
|
755
|
+
case 6:
|
|
756
|
+
return _context.a(2, {
|
|
757
|
+
skippedCreation: true
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
}, _callee);
|
|
761
|
+
})))["finally"](function () {
|
|
762
|
+
cartInitializations.current["delete"](domainId);
|
|
763
|
+
});
|
|
764
|
+
cartInitializations.current.set(domainId, active);
|
|
765
|
+
}
|
|
766
|
+
return active.then(function (result) {
|
|
767
|
+
// An explicit caller can join passive startup before its cookie lookup
|
|
768
|
+
// finishes. Once that no-op completes, create through the same shared
|
|
769
|
+
// initialization path so concurrent explicit callers still issue one POST.
|
|
770
|
+
if (result.skippedCreation && allowCreation) return actionGetMerchiCart();
|
|
771
|
+
return result.cart;
|
|
772
|
+
});
|
|
730
773
|
}
|
|
731
|
-
function clearCart(
|
|
774
|
+
function clearCart(_x5) {
|
|
732
775
|
return _clearCart.apply(this, arguments);
|
|
733
776
|
}
|
|
734
777
|
function _clearCart() {
|
|
735
|
-
_clearCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
736
|
-
return _regenerator().w(function (
|
|
737
|
-
while (1) switch (
|
|
778
|
+
_clearCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(callback) {
|
|
779
|
+
return _regenerator().w(function (_context8) {
|
|
780
|
+
while (1) switch (_context8.n) {
|
|
738
781
|
case 0:
|
|
739
|
-
|
|
782
|
+
_context8.n = 1;
|
|
740
783
|
return createCartAndCookie(function () {
|
|
741
784
|
setAlert(function (previous) {
|
|
742
785
|
return _objectSpread(_objectSpread({}, previous), {}, {
|
|
@@ -747,9 +790,9 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
747
790
|
closeClearCart();
|
|
748
791
|
});
|
|
749
792
|
case 1:
|
|
750
|
-
return
|
|
793
|
+
return _context8.a(2);
|
|
751
794
|
}
|
|
752
|
-
},
|
|
795
|
+
}, _callee8);
|
|
753
796
|
}));
|
|
754
797
|
return _clearCart.apply(this, arguments);
|
|
755
798
|
}
|
|
@@ -757,60 +800,60 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
757
800
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
758
801
|
fetchingShipmentGroups = _useState18[0],
|
|
759
802
|
setFetchingShipmentGroups = _useState18[1];
|
|
760
|
-
function updateCartShipmentAddress(
|
|
803
|
+
function updateCartShipmentAddress(_x6) {
|
|
761
804
|
return _updateCartShipmentAddress.apply(this, arguments);
|
|
762
805
|
}
|
|
763
806
|
function _updateCartShipmentAddress() {
|
|
764
|
-
_updateCartShipmentAddress = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
765
|
-
var token, addressFields, receiverAddress, cartEnt, cartJson, query, cartWithShipmentGroups,
|
|
766
|
-
return _regenerator().w(function (
|
|
767
|
-
while (1) switch (
|
|
807
|
+
_updateCartShipmentAddress = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(address) {
|
|
808
|
+
var token, addressFields, receiverAddress, cartEnt, cartJson, query, cartWithShipmentGroups, _t7;
|
|
809
|
+
return _regenerator().w(function (_context9) {
|
|
810
|
+
while (1) switch (_context9.p = _context9.n) {
|
|
768
811
|
case 0:
|
|
769
|
-
|
|
812
|
+
_context9.n = 1;
|
|
770
813
|
return getCartCookieToken(domainId);
|
|
771
814
|
case 1:
|
|
772
|
-
token =
|
|
815
|
+
token = _context9.v;
|
|
773
816
|
addressFields = sanitizeAddressFields(address);
|
|
774
817
|
receiverAddress = makeAddress(addressFields, true);
|
|
775
818
|
cartEnt = makeCart(cart, false, token);
|
|
776
819
|
setFetchingShipmentGroups(true);
|
|
777
|
-
|
|
820
|
+
_context9.p = 2;
|
|
778
821
|
cartEnt.receiverAddress = receiverAddress;
|
|
779
|
-
|
|
822
|
+
_context9.n = 3;
|
|
780
823
|
return cartEnt.save({
|
|
781
824
|
embed: cartEmbed
|
|
782
825
|
});
|
|
783
826
|
case 3:
|
|
784
|
-
cartEnt =
|
|
827
|
+
cartEnt = _context9.v;
|
|
785
828
|
cartJson = cartEnt.toJson();
|
|
786
829
|
saveCheckoutAddress(domainId, addressFields);
|
|
787
830
|
query = [];
|
|
788
831
|
query.push(['cart_token', cart.token]);
|
|
789
|
-
|
|
832
|
+
_context9.n = 4;
|
|
790
833
|
return merchi.authenticatedFetch("/generate-cart-shipment-quotes/".concat(cart.id, "/"), {
|
|
791
834
|
method: 'GET',
|
|
792
835
|
query: query
|
|
793
836
|
});
|
|
794
837
|
case 4:
|
|
795
|
-
cartWithShipmentGroups =
|
|
838
|
+
cartWithShipmentGroups = _context9.v;
|
|
796
839
|
setCart(_objectSpread(_objectSpread({}, cartJson), {}, {
|
|
797
840
|
shipmentGroups: cartWithShipmentGroups.shipmentGroups || []
|
|
798
841
|
}));
|
|
799
|
-
|
|
842
|
+
_context9.n = 6;
|
|
800
843
|
break;
|
|
801
844
|
case 5:
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
reportCartFailure(
|
|
805
|
-
alertError(
|
|
845
|
+
_context9.p = 5;
|
|
846
|
+
_t7 = _context9.v;
|
|
847
|
+
reportCartFailure(_t7, CART_FAILURE_SOURCES.update);
|
|
848
|
+
alertError(_t7.errorMessage || _t7.message || 'Unable to set address');
|
|
806
849
|
case 6:
|
|
807
|
-
|
|
850
|
+
_context9.p = 6;
|
|
808
851
|
setFetchingShipmentGroups(false);
|
|
809
|
-
return
|
|
852
|
+
return _context9.f(6);
|
|
810
853
|
case 7:
|
|
811
|
-
return
|
|
854
|
+
return _context9.a(2);
|
|
812
855
|
}
|
|
813
|
-
},
|
|
856
|
+
}, _callee9, null, [[2, 5, 6, 7]]);
|
|
814
857
|
}));
|
|
815
858
|
return _updateCartShipmentAddress.apply(this, arguments);
|
|
816
859
|
}
|
|
@@ -818,40 +861,40 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
818
861
|
return _getCartShipmentOptions.apply(this, arguments);
|
|
819
862
|
}
|
|
820
863
|
function _getCartShipmentOptions() {
|
|
821
|
-
_getCartShipmentOptions = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
822
|
-
var query, cartWithGroups,
|
|
823
|
-
return _regenerator().w(function (
|
|
824
|
-
while (1) switch (
|
|
864
|
+
_getCartShipmentOptions = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
865
|
+
var query, cartWithGroups, _t8;
|
|
866
|
+
return _regenerator().w(function (_context0) {
|
|
867
|
+
while (1) switch (_context0.p = _context0.n) {
|
|
825
868
|
case 0:
|
|
826
869
|
setFetchingShipmentGroups(true);
|
|
827
|
-
|
|
870
|
+
_context0.p = 1;
|
|
828
871
|
query = [];
|
|
829
872
|
query.push(['cart_token', cart.token]);
|
|
830
|
-
|
|
873
|
+
_context0.n = 2;
|
|
831
874
|
return merchi.authenticatedFetch("/generate-cart-shipment-quotes/".concat(cart.id, "/"), {
|
|
832
875
|
method: 'GET',
|
|
833
876
|
query: query
|
|
834
877
|
});
|
|
835
878
|
case 2:
|
|
836
|
-
cartWithGroups =
|
|
879
|
+
cartWithGroups = _context0.v;
|
|
837
880
|
setCart(_objectSpread(_objectSpread({}, cart), {}, {
|
|
838
881
|
shipmentGroups: cartWithGroups.shipmentGroups || []
|
|
839
882
|
}));
|
|
840
|
-
|
|
883
|
+
_context0.n = 4;
|
|
841
884
|
break;
|
|
842
885
|
case 3:
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
reportCartFailure(
|
|
846
|
-
alertError(
|
|
886
|
+
_context0.p = 3;
|
|
887
|
+
_t8 = _context0.v;
|
|
888
|
+
reportCartFailure(_t8, CART_FAILURE_SOURCES.shipping);
|
|
889
|
+
alertError(_t8.errorMessage || _t8.message || 'Unable to fetch shipment options');
|
|
847
890
|
case 4:
|
|
848
|
-
|
|
891
|
+
_context0.p = 4;
|
|
849
892
|
setFetchingShipmentGroups(false);
|
|
850
|
-
return
|
|
893
|
+
return _context0.f(4);
|
|
851
894
|
case 5:
|
|
852
|
-
return
|
|
895
|
+
return _context0.a(2);
|
|
853
896
|
}
|
|
854
|
-
},
|
|
897
|
+
}, _callee0, null, [[1, 3, 4, 5]]);
|
|
855
898
|
}));
|
|
856
899
|
return _getCartShipmentOptions.apply(this, arguments);
|
|
857
900
|
}
|
|
@@ -859,14 +902,14 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
859
902
|
return _getMerchiCartValues.apply(this, arguments);
|
|
860
903
|
}
|
|
861
904
|
function _getMerchiCartValues() {
|
|
862
|
-
_getMerchiCartValues = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
863
|
-
var
|
|
864
|
-
return _regenerator().w(function (
|
|
865
|
-
while (1) switch (
|
|
905
|
+
_getMerchiCartValues = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
906
|
+
var _ref4, cartItems, currency, subtotalCost, taxAmount, totalCost, cartItemsCount;
|
|
907
|
+
return _regenerator().w(function (_context1) {
|
|
908
|
+
while (1) switch (_context1.n) {
|
|
866
909
|
case 0:
|
|
867
|
-
|
|
910
|
+
_ref4 = cart, cartItems = _ref4.cartItems, currency = _ref4.currency, subtotalCost = _ref4.subtotalCost, taxAmount = _ref4.taxAmount, totalCost = _ref4.totalCost;
|
|
868
911
|
cartItemsCount = cartItems ? cartItems.length : 0;
|
|
869
|
-
return
|
|
912
|
+
return _context1.a(2, {
|
|
870
913
|
cart: cart,
|
|
871
914
|
cartItemsCount: cartItemsCount,
|
|
872
915
|
currency: currency || '',
|
|
@@ -875,7 +918,7 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
875
918
|
totalCost: totalCost || 0
|
|
876
919
|
});
|
|
877
920
|
}
|
|
878
|
-
},
|
|
921
|
+
}, _callee1);
|
|
879
922
|
}));
|
|
880
923
|
return _getMerchiCartValues.apply(this, arguments);
|
|
881
924
|
}
|
|
@@ -883,13 +926,13 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
883
926
|
return _isMerchiCartFetching.apply(this, arguments);
|
|
884
927
|
}
|
|
885
928
|
function _isMerchiCartFetching() {
|
|
886
|
-
_isMerchiCartFetching = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
887
|
-
return _regenerator().w(function (
|
|
888
|
-
while (1) switch (
|
|
929
|
+
_isMerchiCartFetching = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
930
|
+
return _regenerator().w(function (_context10) {
|
|
931
|
+
while (1) switch (_context10.n) {
|
|
889
932
|
case 0:
|
|
890
|
-
return
|
|
933
|
+
return _context10.a(2, fetchingCart);
|
|
891
934
|
}
|
|
892
|
-
},
|
|
935
|
+
}, _callee10);
|
|
893
936
|
}));
|
|
894
937
|
return _isMerchiCartFetching.apply(this, arguments);
|
|
895
938
|
}
|
|
@@ -903,14 +946,14 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
903
946
|
return _actionFetchTheme.apply(this, arguments);
|
|
904
947
|
}
|
|
905
948
|
function _actionFetchTheme() {
|
|
906
|
-
_actionFetchTheme = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
907
|
-
var domain, theme,
|
|
908
|
-
return _regenerator().w(function (
|
|
909
|
-
while (1) switch (
|
|
949
|
+
_actionFetchTheme = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
950
|
+
var domain, theme, _t9;
|
|
951
|
+
return _regenerator().w(function (_context11) {
|
|
952
|
+
while (1) switch (_context11.p = _context11.n) {
|
|
910
953
|
case 0:
|
|
911
954
|
setLoading(true);
|
|
912
|
-
|
|
913
|
-
|
|
955
|
+
_context11.p = 1;
|
|
956
|
+
_context11.n = 2;
|
|
914
957
|
return merchi.Domain.get(domainId, {
|
|
915
958
|
embed: {
|
|
916
959
|
activeTheme: {
|
|
@@ -919,24 +962,24 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
919
962
|
}
|
|
920
963
|
});
|
|
921
964
|
case 2:
|
|
922
|
-
domain =
|
|
965
|
+
domain = _context11.v;
|
|
923
966
|
theme = domain.activeTheme;
|
|
924
|
-
|
|
967
|
+
_context11.n = 3;
|
|
925
968
|
return appendStyleSheetText(theme.mainCss, function () {
|
|
926
969
|
return setLoading(false);
|
|
927
970
|
});
|
|
928
971
|
case 3:
|
|
929
|
-
|
|
972
|
+
_context11.n = 5;
|
|
930
973
|
break;
|
|
931
974
|
case 4:
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
alertError(
|
|
975
|
+
_context11.p = 4;
|
|
976
|
+
_t9 = _context11.v;
|
|
977
|
+
alertError(_t9.errorMessage || _t9.message || 'Error fetching domain theme.');
|
|
935
978
|
setLoading(false);
|
|
936
979
|
case 5:
|
|
937
|
-
return
|
|
980
|
+
return _context11.a(2);
|
|
938
981
|
}
|
|
939
|
-
},
|
|
982
|
+
}, _callee11, null, [[1, 4]]);
|
|
940
983
|
}));
|
|
941
984
|
return _actionFetchTheme.apply(this, arguments);
|
|
942
985
|
}
|
|
@@ -944,18 +987,18 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
944
987
|
return _setCartComplete.apply(this, arguments);
|
|
945
988
|
}
|
|
946
989
|
function _setCartComplete() {
|
|
947
|
-
_setCartComplete = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
948
|
-
return _regenerator().w(function (
|
|
949
|
-
while (1) switch (
|
|
990
|
+
_setCartComplete = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
991
|
+
return _regenerator().w(function (_context12) {
|
|
992
|
+
while (1) switch (_context12.n) {
|
|
950
993
|
case 0:
|
|
951
|
-
|
|
994
|
+
_context12.n = 1;
|
|
952
995
|
return createCartAndCookie();
|
|
953
996
|
case 1:
|
|
954
997
|
location.reload();
|
|
955
998
|
case 2:
|
|
956
|
-
return
|
|
999
|
+
return _context12.a(2);
|
|
957
1000
|
}
|
|
958
|
-
},
|
|
1001
|
+
}, _callee12);
|
|
959
1002
|
}));
|
|
960
1003
|
return _setCartComplete.apply(this, arguments);
|
|
961
1004
|
}
|
|
@@ -963,16 +1006,16 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
963
1006
|
return _refetchCart.apply(this, arguments);
|
|
964
1007
|
}
|
|
965
1008
|
function _refetchCart() {
|
|
966
|
-
_refetchCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
967
|
-
return _regenerator().w(function (
|
|
968
|
-
while (1) switch (
|
|
1009
|
+
_refetchCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
1010
|
+
return _regenerator().w(function (_context13) {
|
|
1011
|
+
while (1) switch (_context13.n) {
|
|
969
1012
|
case 0:
|
|
970
|
-
|
|
1013
|
+
_context13.n = 1;
|
|
971
1014
|
return actionGetMerchiCart();
|
|
972
1015
|
case 1:
|
|
973
|
-
return
|
|
1016
|
+
return _context13.a(2);
|
|
974
1017
|
}
|
|
975
|
-
},
|
|
1018
|
+
}, _callee13);
|
|
976
1019
|
}));
|
|
977
1020
|
return _refetchCart.apply(this, arguments);
|
|
978
1021
|
}
|
|
@@ -984,26 +1027,49 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
984
1027
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
985
1028
|
loadingTotals = _useState24[0],
|
|
986
1029
|
setLoadingTotals = _useState24[1];
|
|
987
|
-
function addCartItem(
|
|
1030
|
+
function addCartItem(_x7, _x8, _x9) {
|
|
988
1031
|
return _addCartItem.apply(this, arguments);
|
|
989
1032
|
}
|
|
990
1033
|
function _addCartItem() {
|
|
991
|
-
_addCartItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
992
|
-
var jobEnt, cartToken, cartEnt, cartItemEnt,
|
|
993
|
-
return _regenerator().w(function (
|
|
994
|
-
while (1) switch (
|
|
1034
|
+
_addCartItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(jobJson, onSuccess, onError) {
|
|
1035
|
+
var jobEnt, cartItemProduct, readyCart, cartToken, cartEnt, cartItemEnt, item, itemJson, _t0, _t1;
|
|
1036
|
+
return _regenerator().w(function (_context14) {
|
|
1037
|
+
while (1) switch (_context14.p = _context14.n) {
|
|
995
1038
|
case 0:
|
|
996
1039
|
setFetchingCart(true);
|
|
1040
|
+
_context14.p = 1;
|
|
997
1041
|
jobEnt = makeJob(jobJson, true);
|
|
998
|
-
_context12.n = 1;
|
|
999
|
-
return getCartCookieToken(domainId);
|
|
1000
|
-
case 1:
|
|
1001
|
-
cartToken = _context12.v;
|
|
1002
|
-
cartEnt = makeCart(cart, false, cartToken);
|
|
1003
|
-
cartItemEnt = makeCartItem({}, true);
|
|
1004
1042
|
cartItemProduct = makeProduct({
|
|
1005
1043
|
id: jobEnt.product.id
|
|
1006
|
-
});
|
|
1044
|
+
}); // Legacy clients can call addCartItem directly, without first opening
|
|
1045
|
+
// the cart or waiting for React to commit the initialized cart state.
|
|
1046
|
+
if (!(cart !== null && cart !== void 0 && cart.id)) {
|
|
1047
|
+
_context14.n = 2;
|
|
1048
|
+
break;
|
|
1049
|
+
}
|
|
1050
|
+
_t0 = cart;
|
|
1051
|
+
_context14.n = 4;
|
|
1052
|
+
break;
|
|
1053
|
+
case 2:
|
|
1054
|
+
_context14.n = 3;
|
|
1055
|
+
return actionGetMerchiCart();
|
|
1056
|
+
case 3:
|
|
1057
|
+
_t0 = _context14.v;
|
|
1058
|
+
case 4:
|
|
1059
|
+
readyCart = _t0;
|
|
1060
|
+
if (readyCart !== null && readyCart !== void 0 && readyCart.id) {
|
|
1061
|
+
_context14.n = 5;
|
|
1062
|
+
break;
|
|
1063
|
+
}
|
|
1064
|
+
throw new Error('Unable to initialize cart. Please try again.');
|
|
1065
|
+
case 5:
|
|
1066
|
+
setFetchingCart(true);
|
|
1067
|
+
_context14.n = 6;
|
|
1068
|
+
return getCartCookieToken(domainId);
|
|
1069
|
+
case 6:
|
|
1070
|
+
cartToken = _context14.v;
|
|
1071
|
+
cartEnt = makeCart(readyCart, false, cartToken);
|
|
1072
|
+
cartItemEnt = makeCartItem({}, true);
|
|
1007
1073
|
cartItemEnt.cart = cartEnt;
|
|
1008
1074
|
cartItemEnt.quantity = jobEnt.quantity;
|
|
1009
1075
|
cartItemEnt.product = cartItemProduct;
|
|
@@ -1016,30 +1082,29 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
1016
1082
|
if (typeof jobJson.designInputNotes === 'string' && jobJson.designInputNotes) {
|
|
1017
1083
|
cartItemEnt.notes = jobJson.designInputNotes;
|
|
1018
1084
|
}
|
|
1019
|
-
|
|
1020
|
-
_context12.n = 3;
|
|
1085
|
+
_context14.n = 7;
|
|
1021
1086
|
return cartItemEnt.create();
|
|
1022
|
-
case
|
|
1023
|
-
item =
|
|
1024
|
-
|
|
1087
|
+
case 7:
|
|
1088
|
+
item = _context14.v;
|
|
1089
|
+
_context14.n = 8;
|
|
1025
1090
|
return item.toJson();
|
|
1026
|
-
case
|
|
1027
|
-
itemJson =
|
|
1091
|
+
case 8:
|
|
1092
|
+
itemJson = _context14.v;
|
|
1028
1093
|
onSuccess(itemJson);
|
|
1029
|
-
|
|
1094
|
+
_context14.n = 10;
|
|
1030
1095
|
break;
|
|
1031
|
-
case
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
reportAddCartItemFailure(
|
|
1035
|
-
case
|
|
1036
|
-
|
|
1096
|
+
case 9:
|
|
1097
|
+
_context14.p = 9;
|
|
1098
|
+
_t1 = _context14.v;
|
|
1099
|
+
reportAddCartItemFailure(_t1, onError);
|
|
1100
|
+
case 10:
|
|
1101
|
+
_context14.p = 10;
|
|
1037
1102
|
setFetchingCart(false);
|
|
1038
|
-
return
|
|
1039
|
-
case
|
|
1040
|
-
return
|
|
1103
|
+
return _context14.f(10);
|
|
1104
|
+
case 11:
|
|
1105
|
+
return _context14.a(2);
|
|
1041
1106
|
}
|
|
1042
|
-
},
|
|
1107
|
+
}, _callee14, null, [[1, 9, 10, 11]]);
|
|
1043
1108
|
}));
|
|
1044
1109
|
return _addCartItem.apply(this, arguments);
|
|
1045
1110
|
}
|
|
@@ -1063,18 +1128,26 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
1063
1128
|
if (typeof window !== 'undefined') {
|
|
1064
1129
|
window.addCartItem = addCartItem;
|
|
1065
1130
|
window.toggleCartOpen = toggleCartModal;
|
|
1066
|
-
window.getCart = function () {
|
|
1067
|
-
return
|
|
1068
|
-
|
|
1131
|
+
window.getCart = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
1132
|
+
return _regenerator().w(function (_context2) {
|
|
1133
|
+
while (1) switch (_context2.n) {
|
|
1134
|
+
case 0:
|
|
1135
|
+
_context2.n = 1;
|
|
1136
|
+
return actionGetMerchiCart();
|
|
1137
|
+
case 1:
|
|
1138
|
+
return _context2.a(2);
|
|
1139
|
+
}
|
|
1140
|
+
}, _callee2);
|
|
1141
|
+
}));
|
|
1069
1142
|
window.getMerchiCartValues = getMerchiCartValues;
|
|
1070
1143
|
window.isMerchiCartFetching = isMerchiCartFetching;
|
|
1071
1144
|
window.setCartComplete = setCartComplete;
|
|
1072
1145
|
window.refetchCart = refetchCart;
|
|
1073
|
-
window.createCartAndCookie =
|
|
1146
|
+
window.createCartAndCookie = requestNewCart;
|
|
1074
1147
|
}
|
|
1075
1148
|
useEffect(function () {
|
|
1076
1149
|
persistTestCheckoutFlag();
|
|
1077
|
-
if (domainId) actionGetMerchiCart();
|
|
1150
|
+
if (domainId) actionGetMerchiCart(!isAutomatedClient());
|
|
1078
1151
|
if (domainId && includeTheme) actionFetchTheme();
|
|
1079
1152
|
}, [domainId]);
|
|
1080
1153
|
return /*#__PURE__*/_jsx(CartContext.Provider, {
|
|
@@ -1203,7 +1276,7 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
1203
1276
|
// creates a token and cart and then reloads the page
|
|
1204
1277
|
refetchCart: refetchCart,
|
|
1205
1278
|
// used to refetch the cart
|
|
1206
|
-
createCartAndCookie:
|
|
1279
|
+
createCartAndCookie: requestNewCart,
|
|
1207
1280
|
// creates a new cart and cookie
|
|
1208
1281
|
|
|
1209
1282
|
loading: loading,
|