tf-checkout-react 1.3.49-beat.0 → 1.3.49-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -690,13 +690,6 @@ var setLoggedUserData = function setLoggedUserData(data) {
690
690
  };
691
691
  };
692
692
 
693
- var createElementFromHTML = function createElementFromHTML(htmlString) {
694
- var div = document.createElement('div');
695
- div.innerHTML = htmlString.trim();
696
- // Change this to div.childNodes to support multiple top-level nodes.
697
- return div.childNodes || [];
698
- };
699
-
700
693
  var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
701
694
 
702
695
  var isWindowDefined = typeof window !== 'undefined';
@@ -1055,25 +1048,32 @@ function getPixelScript(id, pageOptions) {
1055
1048
  return response;
1056
1049
  }
1057
1050
 
1051
+ function appendScriptsToHeader(code) {
1052
+ if (isBrowser && code) {
1053
+ var tempEl = document.createElement('div');
1054
+ tempEl.innerHTML = code;
1055
+ var scripts = tempEl.getElementsByTagName('script');
1056
+ for (var index = 0; index < scripts.length; ++index) {
1057
+ var script = document.createElement('script');
1058
+ script.type = 'text/javascript';
1059
+ if (scripts[index].src) {
1060
+ script.src = scripts[index].src;
1061
+ } else {
1062
+ script.innerHTML = scripts[index].innerHTML;
1063
+ }
1064
+ document.head.appendChild(script);
1065
+ }
1066
+ }
1067
+ }
1058
1068
  var usePixel = /*#__PURE__*/function () {
1059
1069
  var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(eventId, options) {
1060
- var addPixel, getScript;
1070
+ var getScript;
1061
1071
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1062
1072
  while (1) switch (_context2.prev = _context2.next) {
1063
1073
  case 0:
1064
- addPixel = function addPixel(pixel) {
1065
- var _document;
1066
- if ((_document = document) != null && _document.head && pixel) {
1067
- var nodes = createElementFromHTML(pixel);
1068
- for (var _i = 0, _Array$from = Array.from(nodes); _i < _Array$from.length; _i++) {
1069
- var element = _Array$from[_i];
1070
- document.head.append(element);
1071
- }
1072
- }
1073
- };
1074
1074
  getScript = /*#__PURE__*/function () {
1075
1075
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1076
- var response, pixel;
1076
+ var response, pixels;
1077
1077
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1078
1078
  while (1) switch (_context.prev = _context.next) {
1079
1079
  case 0:
@@ -1088,8 +1088,8 @@ var usePixel = /*#__PURE__*/function () {
1088
1088
  return getPixelScript(eventId, options);
1089
1089
  case 5:
1090
1090
  response = _context.sent;
1091
- pixel = _get(response, 'data.data.attributes.pixels');
1092
- addPixel(pixel);
1091
+ pixels = _get(response, 'data.data.attributes.pixels');
1092
+ appendScriptsToHeader(pixels);
1093
1093
  _context.next = 13;
1094
1094
  break;
1095
1095
  case 10:
@@ -1109,7 +1109,7 @@ var usePixel = /*#__PURE__*/function () {
1109
1109
  React.useEffect(function () {
1110
1110
  getScript();
1111
1111
  }, [eventId]);
1112
- case 3:
1112
+ case 2:
1113
1113
  case "end":
1114
1114
  return _context2.stop();
1115
1115
  }
@@ -3701,7 +3701,7 @@ var PaymentContainer = function PaymentContainer(_ref) {
3701
3701
  setConditions = _useState7[1];
3702
3702
  var showFormTitle = Boolean(formTitle);
3703
3703
  var showErrorText = Boolean(errorText);
3704
- var eventId = getQueryVariable('event_id') || '';
3704
+ var eventId = getQueryVariable('event_id') || _get(reviewData, 'cart[0].product_id') || '';
3705
3705
  var hash = checkoutData.hash,
3706
3706
  total = checkoutData.total;
3707
3707
  var isFreeTickets = !Number(total) && !Number(orderData.total);