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