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