@misiki/gocommerce-connector 0.16.0 → 0.20.0

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/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutResult, v as CheckoutService, w as CmsPage, x as Collection, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, H as Credentials, I as Credit, J as CurrencyService, K as Customer, L as DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, P as Envelope, Q as FacetValue, R as Faq, S as FaqService, T as FeedbackService, U as FooterSettings, V as FreeShipping, W as Fulfillment, X as GalleryService, Y as HeaderSettings, Z as HomeLayout, _ as HomeLayoutSection, $ as HomeService, a0 as IdentityAddress, a1 as InitService, a2 as Invitation, a3 as LayoutCollection, a4 as LayoutPage, a5 as LayoutService, a6 as Lead, a7 as ListMeta, a8 as MeilisearchService, a9 as Member, aa as Menu, ab as MenuItem, ac as MenuService, ad as MenuSummary, ae as Money, af as NewsletterService, ag as Offer, ah as OpeningHours, ai as Order, aj as OrderLine, ak as OrderService, al as PageLayout, am as PageService, an as PaymentIntent, ao as PaymentMethodService, ap as Plugin, aq as PluginService, aq as PluginsService, ar as PopularSearchService, as as PopularityService, at as Postcode, au as Product, av as ProductFacets, aw as ProductOption, ax as ProductService, ay as ProfileService, az as Quote, aA as REDIRECT_GATEWAYS, aB as ReelsService, aC as RegionService, aD as RejectedLine, aE as Review, aF as ReviewPage, aG as ReviewService, aH as SearchDoc, aI as SearchResult, aJ as SearchService, aK as SettingService, aK as SettingsService, aL as ShippingRate, aM as SiteChrome, aN as SiteFooter, aO as SiteHeader, aP as SocialLink, aQ as StateService, aR as StoreProfile, aS as StoreService, aT as StorefrontCategory, aU as StorefrontMenu, aV as StorefrontOrder, aW as StorefrontProduct, aX as ThemeSettings, aY as ThemeSettingsResult, aZ as UploadService, a_ as UserService, a$ as Variant, b0 as VariantImage, b1 as VariantService, b2 as VarniCustomDesignService, b3 as VarniCustomProductService, b4 as Vendor, b5 as VendorService, b6 as WarrantyService, b7 as Wishlist, b8 as WishlistItem, b9 as WishlistService, ba as addressService, bb as authService, bc as autocompleteService, bd as b2bService, be as bannerService, bf as blogService, bg as cartService, bh as categoryService, bi as chatService, bj as checkoutService, bk as collectionService, bl as contactService, bm as countryService, bn as couponService, bo as currencyExponent, bp as currencyService, bq as dealService, br as demoRequestService, bs as emptyCart, bt as emptyPage, bu as enquiryService, bv as faqService, bw as feedbackService, bx as fromEngineAddress, by as fromIdentityAddress, bz as fromSearchDoc, bA as galleryService, bB as homeService, bC as initService, bD as layoutService, bE as mediaUrl, bF as meilisearchService, bG as menuService, bH as minorToMajor, bI as newsletterService, bJ as orderService, bK as ownDomain, bL as pageService, bM as paymentMethodService, bN as pluginService, bO as pluginsService, bP as popularSearchService, bQ as popularityService, bR as priceOf, bS as productImages, bT as productService, bU as productVideos, bV as profileService, bW as qs, bX as reelsService, bY as regionService, bZ as reviewService, b_ as searchService, b$ as setRequestHost, c0 as settingService, c1 as settingsService, c2 as stateService, c3 as staticStore, c4 as storeForHost, c5 as storeService, c6 as toAddOn, c7 as toCart, c8 as toCartLine, c9 as toCartOffer, ca as toCategory, cb as toCmsPage, cc as toCollection, cd as toEngineAddress, ce as toFreeShipping, cf as toIdentityAddress, cg as toMajor, ch as toMinor, ci as toOrder, cj as toPage, ck as toProduct, cl as toRating, cm as toStorefrontFacets, cn as toUser, co as toVariant, cp as toVendor, cq as uploadService, cr as userService, cs as variantService, ct as varniCustomDesignService, cu as varniCustomProductService, cv as vendorService, cw as warrantyService, cx as wishlistService } from './index-Dm_1E1ai.cjs';
1
+ export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutResult, v as CheckoutService, w as CmsPage, x as Collection, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, H as Credentials, I as Credit, J as CurrencyService, K as Customer, L as DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, P as Envelope, Q as FacetValue, R as Faq, S as FaqService, T as FeedbackService, U as FooterSettings, V as FreeShipping, W as Fulfillment, X as GalleryService, Y as GooglePlace, Z as GoogleReview, _ as GoogleReviewService, $ as GoogleReviews, a0 as GoogleSurvey, a1 as HeaderSettings, a2 as HomeLayout, a3 as HomeLayoutSection, a4 as HomeService, a5 as IdentityAddress, a6 as InitService, a7 as Invitation, a8 as LayoutCollection, a9 as LayoutPage, aa as LayoutService, ab as Lead, ac as ListMeta, ad as MeilisearchService, ae as Member, af as Menu, ag as MenuItem, ah as MenuService, ai as MenuSummary, aj as Money, ak as NewsletterService, al as Offer, am as OpeningHours, an as Order, ao as OrderLine, ap as OrderService, aq as PageLayout, ar as PageService, as as PaymentIntent, at as PaymentMethodService, au as Plugin, av as PluginService, av as PluginsService, aw as PopularSearchService, ax as PopularityService, ay as Postcode, az as Product, aA as ProductFacets, aB as ProductOption, aC as ProductService, aD as ProfileService, aE as Quote, aF as REDIRECT_GATEWAYS, aG as ReelsService, aH as RegionService, aI as RejectedLine, aJ as Review, aK as ReviewPage, aL as ReviewService, aM as SearchDoc, aN as SearchResult, aO as SearchService, aP as SettingService, aP as SettingsService, aQ as ShippingRate, aR as SiteChrome, aS as SiteFooter, aT as SiteHeader, aU as SocialLink, aV as StateService, aW as StoreProfile, aX as StoreService, aY as StorefrontCategory, aZ as StorefrontMenu, a_ as StorefrontOrder, a$ as StorefrontProduct, b0 as ThemeSettings, b1 as ThemeSettingsResult, b2 as UploadService, b3 as UserService, b4 as Variant, b5 as VariantImage, b6 as VariantService, b7 as VarniCustomDesignService, b8 as VarniCustomProductService, b9 as Vendor, ba as VendorService, bb as WarrantyService, bc as Wishlist, bd as WishlistItem, be as WishlistService, bf as addressService, bg as authService, bh as autocompleteService, bi as b2bService, bj as bannerService, bk as blogService, bl as cartService, bm as categoryService, bn as chatService, bo as checkoutService, bp as collectionService, bq as contactService, br as countryService, bs as couponService, bt as currencyExponent, bu as currencyService, bv as dealService, bw as demoRequestService, bx as emptyCart, by as emptyPage, bz as enquiryService, bA as faqService, bB as feedbackService, bC as fromEngineAddress, bD as fromIdentityAddress, bE as fromSearchDoc, bF as galleryService, bG as googleReviewService, bH as homeService, bI as initService, bJ as layoutService, bK as mediaUrl, bL as meilisearchService, bM as menuService, bN as minorToMajor, bO as newsletterService, bP as orderService, bQ as ownDomain, bR as pageService, bS as paymentMethodService, bT as pluginService, bU as pluginsService, bV as popularSearchService, bW as popularityService, bX as priceOf, bY as productImages, bZ as productService, b_ as productVideos, b$ as profileService, c0 as qs, c1 as reelsService, c2 as regionService, c3 as reviewService, c4 as searchService, c5 as setRequestHost, c6 as settingService, c7 as settingsService, c8 as stateService, c9 as staticStore, ca as storeForHost, cb as storeService, cc as toAddOn, cd as toCart, ce as toCartLine, cf as toCartOffer, cg as toCategory, ch as toCmsPage, ci as toCollection, cj as toEngineAddress, ck as toFreeShipping, cl as toIdentityAddress, cm as toMajor, cn as toMinor, co as toOrder, cp as toPage, cq as toProduct, cr as toRating, cs as toStorefrontFacets, ct as toUser, cu as toVariant, cv as toVendor, cw as uploadService, cx as userService, cy as variantService, cz as varniCustomDesignService, cA as varniCustomProductService, cB as vendorService, cC as warrantyService, cD as wishlistService } from './index-BnLRuRag.cjs';
2
2
 
3
3
  /**
4
4
  * The two ways a call through this connector fails.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutResult, v as CheckoutService, w as CmsPage, x as Collection, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, H as Credentials, I as Credit, J as CurrencyService, K as Customer, L as DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, P as Envelope, Q as FacetValue, R as Faq, S as FaqService, T as FeedbackService, U as FooterSettings, V as FreeShipping, W as Fulfillment, X as GalleryService, Y as HeaderSettings, Z as HomeLayout, _ as HomeLayoutSection, $ as HomeService, a0 as IdentityAddress, a1 as InitService, a2 as Invitation, a3 as LayoutCollection, a4 as LayoutPage, a5 as LayoutService, a6 as Lead, a7 as ListMeta, a8 as MeilisearchService, a9 as Member, aa as Menu, ab as MenuItem, ac as MenuService, ad as MenuSummary, ae as Money, af as NewsletterService, ag as Offer, ah as OpeningHours, ai as Order, aj as OrderLine, ak as OrderService, al as PageLayout, am as PageService, an as PaymentIntent, ao as PaymentMethodService, ap as Plugin, aq as PluginService, aq as PluginsService, ar as PopularSearchService, as as PopularityService, at as Postcode, au as Product, av as ProductFacets, aw as ProductOption, ax as ProductService, ay as ProfileService, az as Quote, aA as REDIRECT_GATEWAYS, aB as ReelsService, aC as RegionService, aD as RejectedLine, aE as Review, aF as ReviewPage, aG as ReviewService, aH as SearchDoc, aI as SearchResult, aJ as SearchService, aK as SettingService, aK as SettingsService, aL as ShippingRate, aM as SiteChrome, aN as SiteFooter, aO as SiteHeader, aP as SocialLink, aQ as StateService, aR as StoreProfile, aS as StoreService, aT as StorefrontCategory, aU as StorefrontMenu, aV as StorefrontOrder, aW as StorefrontProduct, aX as ThemeSettings, aY as ThemeSettingsResult, aZ as UploadService, a_ as UserService, a$ as Variant, b0 as VariantImage, b1 as VariantService, b2 as VarniCustomDesignService, b3 as VarniCustomProductService, b4 as Vendor, b5 as VendorService, b6 as WarrantyService, b7 as Wishlist, b8 as WishlistItem, b9 as WishlistService, ba as addressService, bb as authService, bc as autocompleteService, bd as b2bService, be as bannerService, bf as blogService, bg as cartService, bh as categoryService, bi as chatService, bj as checkoutService, bk as collectionService, bl as contactService, bm as countryService, bn as couponService, bo as currencyExponent, bp as currencyService, bq as dealService, br as demoRequestService, bs as emptyCart, bt as emptyPage, bu as enquiryService, bv as faqService, bw as feedbackService, bx as fromEngineAddress, by as fromIdentityAddress, bz as fromSearchDoc, bA as galleryService, bB as homeService, bC as initService, bD as layoutService, bE as mediaUrl, bF as meilisearchService, bG as menuService, bH as minorToMajor, bI as newsletterService, bJ as orderService, bK as ownDomain, bL as pageService, bM as paymentMethodService, bN as pluginService, bO as pluginsService, bP as popularSearchService, bQ as popularityService, bR as priceOf, bS as productImages, bT as productService, bU as productVideos, bV as profileService, bW as qs, bX as reelsService, bY as regionService, bZ as reviewService, b_ as searchService, b$ as setRequestHost, c0 as settingService, c1 as settingsService, c2 as stateService, c3 as staticStore, c4 as storeForHost, c5 as storeService, c6 as toAddOn, c7 as toCart, c8 as toCartLine, c9 as toCartOffer, ca as toCategory, cb as toCmsPage, cc as toCollection, cd as toEngineAddress, ce as toFreeShipping, cf as toIdentityAddress, cg as toMajor, ch as toMinor, ci as toOrder, cj as toPage, ck as toProduct, cl as toRating, cm as toStorefrontFacets, cn as toUser, co as toVariant, cp as toVendor, cq as uploadService, cr as userService, cs as variantService, ct as varniCustomDesignService, cu as varniCustomProductService, cv as vendorService, cw as warrantyService, cx as wishlistService } from './index-Dm_1E1ai.js';
1
+ export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutResult, v as CheckoutService, w as CmsPage, x as Collection, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, H as Credentials, I as Credit, J as CurrencyService, K as Customer, L as DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, P as Envelope, Q as FacetValue, R as Faq, S as FaqService, T as FeedbackService, U as FooterSettings, V as FreeShipping, W as Fulfillment, X as GalleryService, Y as GooglePlace, Z as GoogleReview, _ as GoogleReviewService, $ as GoogleReviews, a0 as GoogleSurvey, a1 as HeaderSettings, a2 as HomeLayout, a3 as HomeLayoutSection, a4 as HomeService, a5 as IdentityAddress, a6 as InitService, a7 as Invitation, a8 as LayoutCollection, a9 as LayoutPage, aa as LayoutService, ab as Lead, ac as ListMeta, ad as MeilisearchService, ae as Member, af as Menu, ag as MenuItem, ah as MenuService, ai as MenuSummary, aj as Money, ak as NewsletterService, al as Offer, am as OpeningHours, an as Order, ao as OrderLine, ap as OrderService, aq as PageLayout, ar as PageService, as as PaymentIntent, at as PaymentMethodService, au as Plugin, av as PluginService, av as PluginsService, aw as PopularSearchService, ax as PopularityService, ay as Postcode, az as Product, aA as ProductFacets, aB as ProductOption, aC as ProductService, aD as ProfileService, aE as Quote, aF as REDIRECT_GATEWAYS, aG as ReelsService, aH as RegionService, aI as RejectedLine, aJ as Review, aK as ReviewPage, aL as ReviewService, aM as SearchDoc, aN as SearchResult, aO as SearchService, aP as SettingService, aP as SettingsService, aQ as ShippingRate, aR as SiteChrome, aS as SiteFooter, aT as SiteHeader, aU as SocialLink, aV as StateService, aW as StoreProfile, aX as StoreService, aY as StorefrontCategory, aZ as StorefrontMenu, a_ as StorefrontOrder, a$ as StorefrontProduct, b0 as ThemeSettings, b1 as ThemeSettingsResult, b2 as UploadService, b3 as UserService, b4 as Variant, b5 as VariantImage, b6 as VariantService, b7 as VarniCustomDesignService, b8 as VarniCustomProductService, b9 as Vendor, ba as VendorService, bb as WarrantyService, bc as Wishlist, bd as WishlistItem, be as WishlistService, bf as addressService, bg as authService, bh as autocompleteService, bi as b2bService, bj as bannerService, bk as blogService, bl as cartService, bm as categoryService, bn as chatService, bo as checkoutService, bp as collectionService, bq as contactService, br as countryService, bs as couponService, bt as currencyExponent, bu as currencyService, bv as dealService, bw as demoRequestService, bx as emptyCart, by as emptyPage, bz as enquiryService, bA as faqService, bB as feedbackService, bC as fromEngineAddress, bD as fromIdentityAddress, bE as fromSearchDoc, bF as galleryService, bG as googleReviewService, bH as homeService, bI as initService, bJ as layoutService, bK as mediaUrl, bL as meilisearchService, bM as menuService, bN as minorToMajor, bO as newsletterService, bP as orderService, bQ as ownDomain, bR as pageService, bS as paymentMethodService, bT as pluginService, bU as pluginsService, bV as popularSearchService, bW as popularityService, bX as priceOf, bY as productImages, bZ as productService, b_ as productVideos, b$ as profileService, c0 as qs, c1 as reelsService, c2 as regionService, c3 as reviewService, c4 as searchService, c5 as setRequestHost, c6 as settingService, c7 as settingsService, c8 as stateService, c9 as staticStore, ca as storeForHost, cb as storeService, cc as toAddOn, cd as toCart, ce as toCartLine, cf as toCartOffer, cg as toCategory, ch as toCmsPage, ci as toCollection, cj as toEngineAddress, ck as toFreeShipping, cl as toIdentityAddress, cm as toMajor, cn as toMinor, co as toOrder, cp as toPage, cq as toProduct, cr as toRating, cs as toStorefrontFacets, ct as toUser, cu as toVariant, cv as toVendor, cw as uploadService, cx as userService, cy as variantService, cz as varniCustomDesignService, cA as varniCustomProductService, cB as vendorService, cC as warrantyService, cD as wishlistService } from './index-BnLRuRag.js';
2
2
 
3
3
  /**
4
4
  * The two ways a call through this connector fails.
package/dist/index.js CHANGED
@@ -234,6 +234,17 @@ function currentMe() {
234
234
  return null;
235
235
  }
236
236
  }
237
+ function metaBrowser() {
238
+ const fbp = readCookie("_fbp");
239
+ if (!fbp || typeof window.fbq !== "function") return void 0;
240
+ const fbc = readCookie("_fbc");
241
+ return {
242
+ fbp,
243
+ ...fbc ? { fbc } : {},
244
+ client_user_agent: window.navigator.userAgent,
245
+ event_source_url: window.location.origin + window.location.pathname
246
+ };
247
+ }
237
248
  function storedCartId() {
238
249
  const v = readLocal("cart_id");
239
250
  if (!v || v === "undefined" || v === "null") return null;
@@ -2205,11 +2216,13 @@ var CheckoutService = class extends BaseService {
2205
2216
  ...extra
2206
2217
  };
2207
2218
  const serialised = JSON.stringify(body);
2208
- const key = extras.attempt?.body === `${code}:${serialised}` ? extras.attempt.key : newKey();
2209
- saveCartExtras(id2, { attempt: { key, body: `${code}:${serialised}` } });
2219
+ const retry = extras.attempt?.body === `${code}:${serialised}`;
2220
+ const key = retry ? extras.attempt.key : newKey();
2221
+ const meta = retry ? extras.attempt?.meta : metaBrowser();
2222
+ saveCartExtras(id2, { attempt: { key, body: `${code}:${serialised}`, ...meta ? { meta } : {} } });
2210
2223
  const result = await this.data(`/api/checkout/${encodeURIComponent(code)}`, {
2211
2224
  method: "POST",
2212
- body,
2225
+ body: meta ? { ...body, metadata: { ...extra.metadata, meta_capi: meta } } : body,
2213
2226
  headers: { "Idempotency-Key": key }
2214
2227
  });
2215
2228
  if (result.order.access_token) {
@@ -2871,6 +2884,71 @@ var ReviewService = class extends BaseService {
2871
2884
  };
2872
2885
  var reviewService = new ReviewService();
2873
2886
 
2887
+ // src/services/google-review-service.ts
2888
+ var PLUGIN = "google-reviews";
2889
+ var GoogleReviewService = class extends BaseService {
2890
+ facts = new StoreFacts(this._fetch);
2891
+ /**
2892
+ * Google's rating and its most relevant reviews, read live. Google's terms
2893
+ * forbid keeping them, so nothing here caches them either, and every call
2894
+ * is one the store pays Google for: call it when the section is in view.
2895
+ */
2896
+ async place() {
2897
+ if (!await this.switchOn("show_place")) return null;
2898
+ const p = await this.orNull(() => this.data("/x/google-reviews/place"));
2899
+ if (!p?.user_rating_count) return null;
2900
+ return {
2901
+ rating: p.rating,
2902
+ count: p.user_rating_count,
2903
+ mapsUrl: p.google_maps_uri ?? "",
2904
+ reviews: (p.reviews ?? []).map((r) => ({
2905
+ author: r.author?.name ?? "",
2906
+ authorUrl: r.author?.uri ?? "",
2907
+ authorPhoto: r.author?.photo_uri ?? "",
2908
+ rating: r.rating,
2909
+ text: r.text ?? "",
2910
+ language: r.language ?? "",
2911
+ when: r.relative_time ?? "",
2912
+ visited: r.visit_date ?? "",
2913
+ url: r.google_maps_uri ?? "",
2914
+ reportUrl: r.flag_uri ?? ""
2915
+ }))
2916
+ };
2917
+ }
2918
+ /**
2919
+ * What Google Customer Reviews' opt-in is rendered with, for an order placed
2920
+ * in this browser: its access token is kept here, and nowhere else can ask.
2921
+ * Every field is the order's own; the keys are Google's, to pass unchanged
2922
+ * to `gapi.surveyoptin.render`.
2923
+ */
2924
+ async survey(orderNumber) {
2925
+ const kept = orderNumber ? placedOrder(orderNumber) : void 0;
2926
+ if (!kept || !await this.switchOn("customer_reviews")) return null;
2927
+ return this.orNull(
2928
+ () => this.data(`/x/google-reviews/survey/${encodeURIComponent(orderNumber)}`, {
2929
+ query: { token: kept.token }
2930
+ })
2931
+ );
2932
+ }
2933
+ async switchOn(setting) {
2934
+ try {
2935
+ return (await this.facts.plugins()).get(PLUGIN)?.settings?.[setting] === true;
2936
+ } catch {
2937
+ return false;
2938
+ }
2939
+ }
2940
+ /** Off, used up for the day, or refused by Google: nothing to show. Anything else still throws. */
2941
+ async orNull(call) {
2942
+ try {
2943
+ return await call();
2944
+ } catch (err) {
2945
+ if (err instanceof GoCommerceError && [404, 429, 502].includes(err.status)) return null;
2946
+ throw err;
2947
+ }
2948
+ }
2949
+ };
2950
+ var googleReviewService = new GoogleReviewService();
2951
+
2874
2952
  // src/services/menu-service.ts
2875
2953
  function linkFor(item) {
2876
2954
  const t = item.target ?? "";
@@ -3089,9 +3167,21 @@ var StoreService = class extends BaseService {
3089
3167
  ...basePlugins.isProductReviewsAndRatings,
3090
3168
  ...flag(plugins.has("product-reviews"))
3091
3169
  },
3170
+ // Google Customer Reviews (ext/google-reviews): the confirmation page's survey offer,
3171
+ // whose fields the engine builds from the order, and Google's store widget, which
3172
+ // belongs to the same programme and so needs the survey on.
3173
+ googleReviewsOptIn: {
3174
+ ...basePlugins.googleReviewsOptIn,
3175
+ ...flag(googleSetting(plugins, "customer_reviews") === true)
3176
+ },
3177
+ googleStoreWidget: storeWidget(plugins),
3092
3178
  // The footer's sign-up box posts to ext/newsletter, and the theme editor's footer
3093
3179
  // switch (D131) can only show it while that is on.
3094
3180
  newsletter: { ...basePlugins.newsletter, ...flag(plugins.has("newsletter")) },
3181
+ // The ad and analytics tags (D160). The engine decides, not the static record:
3182
+ // one storefront serves every store, and one store's pixel must never
3183
+ // load on another's pages.
3184
+ ...adTags(plugins),
3095
3185
  // Discount codes are core: every GoCommerce store takes them, so
3096
3186
  // the code box is shown whatever the static record says.
3097
3187
  isDiscountCoupons: { ...basePlugins.isDiscountCoupons, active: true },
@@ -3117,6 +3207,22 @@ var StoreService = class extends BaseService {
3117
3207
  }
3118
3208
  };
3119
3209
  var storeService = new StoreService();
3210
+ var AD_TAGS = [
3211
+ ["meta-pixel", "pixel_id", "facebookPixel"],
3212
+ ["microsoft-clarity", "project_id", "microsoftClarity"],
3213
+ ["hotjar", "site_id", "hotjar"],
3214
+ ["tiktok-pixel", "pixel_id", "tiktokPixel"],
3215
+ ["pinterest-tag", "tag_id", "pinterestTag"],
3216
+ ["snapchat-pixel", "pixel_id", "snapchatPixel"]
3217
+ ];
3218
+ function adTags(plugins) {
3219
+ return Object.fromEntries(
3220
+ AD_TAGS.map(([key, field, name]) => {
3221
+ const id2 = String(plugins.get(key)?.settings?.[field] ?? "").trim();
3222
+ return [name, id2 ? { active: true, id: id2 } : { active: false }];
3223
+ })
3224
+ );
3225
+ }
3120
3226
  function deliverable(base, ships) {
3121
3227
  if (ships.everywhere || !ships.countries.length) return {};
3122
3228
  const known = new Map((base.countries ?? []).map((c) => [String(c.code).toUpperCase(), c]));
@@ -3131,6 +3237,12 @@ function regionName(code) {
3131
3237
  return code;
3132
3238
  }
3133
3239
  }
3240
+ var googleSetting = (plugins, key) => plugins.get("google-reviews")?.settings?.[key];
3241
+ function storeWidget(plugins) {
3242
+ const where = googleSetting(plugins, "store_widget");
3243
+ if (googleSetting(plugins, "customer_reviews") !== true || !where) return { active: false };
3244
+ return { active: true, position: where === "Bottom left" ? "LEFT_BOTTOM" : "RIGHT_BOTTOM" };
3245
+ }
3134
3246
  var LOGIN_TYPES = { phone_otp: "PHONE", email_or_phone: "BOTH", email_password: "EMAIL" };
3135
3247
 
3136
3248
  // src/services/page-service.ts
@@ -3813,6 +3925,6 @@ function attemptKey(request) {
3813
3925
  }
3814
3926
  var b2bService = new B2bService();
3815
3927
 
3816
- export { AddressService, AuthService, AutocompleteService, B2bService, BannerService, BaseService, BlogService, CartService, CatalogService, CategoryService, ChatService, CheckoutService, CollectionService, ContactService, CountryService, CouponService, CurrencyService, DealService, DemoRequestService, EnquiryService, FaqService, FeedbackService, GalleryService, GoCommerceError, HomeService, InitService, LayoutService, MeilisearchService, MenuService, NewsletterService, NotSupportedError, OrderService, PageService, PaymentMethodService, PluginService, PluginService as PluginsService, PopularSearchService, PopularityService, ProductService, ProfileService, REDIRECT_GATEWAYS, ReelsService, RegionService, ReviewService, SearchService, SettingService, SettingService as SettingsService, StateService, StoreService, UploadService, UserService, VariantService, VarniCustomDesignService, VarniCustomProductService, VendorService, WarrantyService, WishlistService, addressService, authService, autocompleteService, b2bService, bannerService, blogService, cartService, categoryService, chatService, checkoutService, forgetAll as clearStoreCache, collectionService, connectorName, contactService, countryService, couponService, currencyExponent, currencyService, dealService, demoRequestService, emptyCart, emptyPage, enquiryService, faqService, feedbackService, fromEngineAddress, fromIdentityAddress, fromSearchDoc, galleryService, hasStaticStore, homeService, initService, layoutService, mediaUrl, meilisearchService, menuService, minorToMajor, newsletterService, orderService, ownDomain, pageService, paymentMethodService, pluginService, pluginsService, popularSearchService, popularityService, priceOf, productImages, productService, productVideos, profileService, qs, readStaticStore, reelsService, regionService, reviewService, searchService, serveRestLocally, setRequestHost, setStaticStore, settingService, settingsService, stateService, staticStore, storeForHost, storeService, toAddOn, toCart, toCartLine, toCartOffer, toCategory, toCmsPage, toCollection, toEngineAddress, toFreeShipping, toIdentityAddress, toMajor, toMinor, toOrder, toPage, toProduct, toRating, toStorefrontFacets, toUser, toVariant, toVendor, uploadService, userService, variantService, varniCustomDesignService, varniCustomProductService, vendorService, warrantyService, wishlistService };
3928
+ export { AddressService, AuthService, AutocompleteService, B2bService, BannerService, BaseService, BlogService, CartService, CatalogService, CategoryService, ChatService, CheckoutService, CollectionService, ContactService, CountryService, CouponService, CurrencyService, DealService, DemoRequestService, EnquiryService, FaqService, FeedbackService, GalleryService, GoCommerceError, GoogleReviewService, HomeService, InitService, LayoutService, MeilisearchService, MenuService, NewsletterService, NotSupportedError, OrderService, PageService, PaymentMethodService, PluginService, PluginService as PluginsService, PopularSearchService, PopularityService, ProductService, ProfileService, REDIRECT_GATEWAYS, ReelsService, RegionService, ReviewService, SearchService, SettingService, SettingService as SettingsService, StateService, StoreService, UploadService, UserService, VariantService, VarniCustomDesignService, VarniCustomProductService, VendorService, WarrantyService, WishlistService, addressService, authService, autocompleteService, b2bService, bannerService, blogService, cartService, categoryService, chatService, checkoutService, forgetAll as clearStoreCache, collectionService, connectorName, contactService, countryService, couponService, currencyExponent, currencyService, dealService, demoRequestService, emptyCart, emptyPage, enquiryService, faqService, feedbackService, fromEngineAddress, fromIdentityAddress, fromSearchDoc, galleryService, googleReviewService, hasStaticStore, homeService, initService, layoutService, mediaUrl, meilisearchService, menuService, minorToMajor, newsletterService, orderService, ownDomain, pageService, paymentMethodService, pluginService, pluginsService, popularSearchService, popularityService, priceOf, productImages, productService, productVideos, profileService, qs, readStaticStore, reelsService, regionService, reviewService, searchService, serveRestLocally, setRequestHost, setStaticStore, settingService, settingsService, stateService, staticStore, storeForHost, storeService, toAddOn, toCart, toCartLine, toCartOffer, toCategory, toCmsPage, toCollection, toEngineAddress, toFreeShipping, toIdentityAddress, toMajor, toMinor, toOrder, toPage, toProduct, toRating, toStorefrontFacets, toUser, toVariant, toVendor, uploadService, userService, variantService, varniCustomDesignService, varniCustomProductService, vendorService, warrantyService, wishlistService };
3817
3929
  //# sourceMappingURL=index.js.map
3818
3930
  //# sourceMappingURL=index.js.map