@misiki/gocommerce-connector 0.19.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-BsvUnF4H.d.cts → index-BnLRuRag.d.cts} +5 -1
- package/dist/{index-BsvUnF4H.d.ts → index-BnLRuRag.d.ts} +5 -1
- package/dist/index.cjs +36 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +36 -3
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +36 -3
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +36 -3
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
package/dist/services/index.cjs
CHANGED
|
@@ -163,6 +163,17 @@ function currentMe() {
|
|
|
163
163
|
return null;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
+
function metaBrowser() {
|
|
167
|
+
const fbp = readCookie("_fbp");
|
|
168
|
+
if (!fbp || typeof window.fbq !== "function") return void 0;
|
|
169
|
+
const fbc = readCookie("_fbc");
|
|
170
|
+
return {
|
|
171
|
+
fbp,
|
|
172
|
+
...fbc ? { fbc } : {},
|
|
173
|
+
client_user_agent: window.navigator.userAgent,
|
|
174
|
+
event_source_url: window.location.origin + window.location.pathname
|
|
175
|
+
};
|
|
176
|
+
}
|
|
166
177
|
function storedCartId() {
|
|
167
178
|
const v = readLocal("cart_id");
|
|
168
179
|
if (!v || v === "undefined" || v === "null") return null;
|
|
@@ -2188,11 +2199,13 @@ var CheckoutService = class extends BaseService {
|
|
|
2188
2199
|
...extra
|
|
2189
2200
|
};
|
|
2190
2201
|
const serialised = JSON.stringify(body);
|
|
2191
|
-
const
|
|
2192
|
-
|
|
2202
|
+
const retry = extras.attempt?.body === `${code}:${serialised}`;
|
|
2203
|
+
const key = retry ? extras.attempt.key : newKey();
|
|
2204
|
+
const meta = retry ? extras.attempt?.meta : metaBrowser();
|
|
2205
|
+
saveCartExtras(id2, { attempt: { key, body: `${code}:${serialised}`, ...meta ? { meta } : {} } });
|
|
2193
2206
|
const result = await this.data(`/api/checkout/${encodeURIComponent(code)}`, {
|
|
2194
2207
|
method: "POST",
|
|
2195
|
-
body,
|
|
2208
|
+
body: meta ? { ...body, metadata: { ...extra.metadata, meta_capi: meta } } : body,
|
|
2196
2209
|
headers: { "Idempotency-Key": key }
|
|
2197
2210
|
});
|
|
2198
2211
|
if (result.order.access_token) {
|
|
@@ -3151,6 +3164,10 @@ var StoreService = class extends BaseService {
|
|
|
3151
3164
|
// The footer's sign-up box posts to ext/newsletter, and the theme editor's footer
|
|
3152
3165
|
// switch (D131) can only show it while that is on.
|
|
3153
3166
|
newsletter: { ...basePlugins.newsletter, ...flag(plugins.has("newsletter")) },
|
|
3167
|
+
// The ad and analytics tags (D160). The engine decides, not the static record:
|
|
3168
|
+
// one storefront serves every store, and one store's pixel must never
|
|
3169
|
+
// load on another's pages.
|
|
3170
|
+
...adTags(plugins),
|
|
3154
3171
|
// Discount codes are core: every GoCommerce store takes them, so
|
|
3155
3172
|
// the code box is shown whatever the static record says.
|
|
3156
3173
|
isDiscountCoupons: { ...basePlugins.isDiscountCoupons, active: true },
|
|
@@ -3176,6 +3193,22 @@ var StoreService = class extends BaseService {
|
|
|
3176
3193
|
}
|
|
3177
3194
|
};
|
|
3178
3195
|
var storeService = new StoreService();
|
|
3196
|
+
var AD_TAGS = [
|
|
3197
|
+
["meta-pixel", "pixel_id", "facebookPixel"],
|
|
3198
|
+
["microsoft-clarity", "project_id", "microsoftClarity"],
|
|
3199
|
+
["hotjar", "site_id", "hotjar"],
|
|
3200
|
+
["tiktok-pixel", "pixel_id", "tiktokPixel"],
|
|
3201
|
+
["pinterest-tag", "tag_id", "pinterestTag"],
|
|
3202
|
+
["snapchat-pixel", "pixel_id", "snapchatPixel"]
|
|
3203
|
+
];
|
|
3204
|
+
function adTags(plugins) {
|
|
3205
|
+
return Object.fromEntries(
|
|
3206
|
+
AD_TAGS.map(([key, field, name]) => {
|
|
3207
|
+
const id2 = String(plugins.get(key)?.settings?.[field] ?? "").trim();
|
|
3208
|
+
return [name, id2 ? { active: true, id: id2 } : { active: false }];
|
|
3209
|
+
})
|
|
3210
|
+
);
|
|
3211
|
+
}
|
|
3179
3212
|
function deliverable(base, ships) {
|
|
3180
3213
|
if (ships.everywhere || !ships.countries.length) return {};
|
|
3181
3214
|
const known = new Map((base.countries ?? []).map((c) => [String(c.code).toUpperCase(), c]));
|