1 line
6.0 KiB
JavaScript
1 line
6.0 KiB
JavaScript
!function(t){var e={};function o(n){if(e[n])return e[n].exports;var c=e[n]={i:n,l:!1,exports:{}};return t[n].call(c.exports,c,c.exports,o),c.l=!0,c.exports}o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var c in t)o.d(n,c,function(e){return t[e]}.bind(null,c));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=5)}([function(t,e){t.exports=window.wp.hooks},function(t,e){t.exports=window.wp.i18n},function(t,e){t.exports=function(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,o){var n=o(4);t.exports=function(t,e){if(null==t)return{};var o,c,r=n(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(c=0;c<i.length;c++)o=i[c],e.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(t,o)&&(r[o]=t[o])}return r},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t,e){if(null==t)return{};var o,n,c={},r=Object.keys(t);for(n=0;n<r.length;n++)o=r[n],e.indexOf(o)>=0||(c[o]=t[o]);return c},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,o){"use strict";o.r(e);var n=o(2),c=o.n(n),r=o(3),i=o.n(r),a=o(1),u=o(0),s="woocommerce-google-analytics",p="experimental__woocommerce_blocks",d=function(t,e){var o=t.sku?t.sku:"#"+t.id,n="categories"in t&&t.categories.length?t.categories[0].name:"";return{id:o,name:t.name,quantity:e,category:n,price:(parseInt(t.prices.price,10)/Math.pow(10,t.prices.currency_minor_unit)).toString()}},l=function(t,e){var o=t.sku?t.sku:"#"+t.id,n=t.categories.length?t.categories[0].name:"";return{id:o,name:t.name,list_name:e,category:n,price:(parseInt(t.prices.price,10)/Math.pow(10,t.prices.currency_minor_unit)).toString()}},f=function(t,e){if("function"!=typeof gtag)throw new Error("Function gtag not implemented.");console.log("Tracking event ".concat(t)),window.gtag("event",t,e)},b=-1,g=function(t){return function(e){var o,n=e.storeCart;b!==t&&(f(0===t?"begin_checkout":"checkout_progress",{items:n.cartItems.map(d),coupon:(null===(o=n.cartCoupons[0])||void 0===o?void 0:o.code)||"",currency:n.cartTotals.currency_code,value:(parseInt(n.cartTotals.total_price,10)/Math.pow(10,n.cartTotals.currency_minor_unit)).toString(),checkout_step:t}),b=t)}},m=function(t){var e=t.step,o=t.option,n=t.value;return function(){f("set_checkout_option",{checkout_step:e,checkout_option:o,value:n}),b=e}},_=["step"];function v(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,n)}return o}function y(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?v(Object(o),!0).forEach((function(e){c()(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):v(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}Object(u.addAction)("".concat(p,"-checkout-render-checkout-form"),s,g(0)),Object(u.addAction)("".concat(p,"-checkout-set-email-address"),s,g(1)),Object(u.addAction)("".concat(p,"-checkout-set-shipping-address"),s,g(2)),Object(u.addAction)("".concat(p,"-checkout-set-billing-address"),s,g(3)),Object(u.addAction)("".concat(p,"-checkout-set-phone-number"),s,(function(t){var e=t.step,o=i()(t,_);g("shipping"===e?2:3)(o)})),Object(u.addAction)("".concat(p,"-checkout-set-selected-shipping-rate"),s,(function(t){var e=t.shippingRateId;m({step:4,option:Object(a.__)("Shipping Method",'woocommerce'),value:e})()})),Object(u.addAction)("".concat(p,"-checkout-set-active-payment-method"),s,(function(t){var e=t.paymentMethodSlug;m({step:5,option:Object(a.__)("Payment Method",'woocommerce'),value:e})()})),Object(u.addAction)("".concat(p,"-checkout-submit"),s,(function(){f("add_payment_info")})),Object(u.addAction)("".concat(p,"-cart-add-item"),s,(function(t){var e=t.product,o=t.quantity,n=void 0===o?1:o;f("add_to_cart",{event_category:"ecommerce",event_label:Object(a.__)("Add to Cart",'woocommerce'),items:[d(e,n)]})})),Object(u.addAction)("".concat(p,"-cart-remove-item"),s,(function(t){var e=t.product,o=t.quantity,n=void 0===o?1:o;f("remove_from_cart",{event_category:"ecommerce",event_label:Object(a.__)("Remove Cart Item",'woocommerce'),items:[d(e,n)]})})),Object(u.addAction)("".concat(p,"-cart-set-item-quantity"),s,(function(t){var e=t.product,o=t.quantity,n=void 0===o?1:o;f("change_cart_quantity",{event_category:"ecommerce",event_label:Object(a.__)("Change Cart Item Quantity",'woocommerce'),items:[d(e,n)]})})),Object(u.addAction)("".concat(p,"-product-list-render"),s,(function(t){var e=t.products,o=t.listName,n=void 0===o?Object(a.__)("Product List",'woocommerce'):o;0!==e.length&&f("view_item_list",{event_category:"engagement",event_label:Object(a.__)("Viewing products",'woocommerce'),items:e.map((function(t,e){return y(y({},l(t,n)),{},{list_position:e+1})}))})})),Object(u.addAction)("".concat(p,"-product-view-link"),s,(function(t){var e=t.product,o=t.listName;f("select_content",{content_type:"product",items:[l(e,o)]})})),Object(u.addAction)("".concat(p,"-product-search"),s,(function(t){var e=t.searchTerm;f("search",{search_term:e})})),Object(u.addAction)("".concat(p,"-product-render"),s,(function(t){var e=t.product,o=t.listName;e&&f("view_item",{items:[l(e,o)]})})),Object(u.addAction)("".concat(p,"-store-notice-create"),s,(function(t){var e=t.status,o=t.content;"error"===e&&f("exception",{description:o,fatal:!1})}))}]); |