@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
|
@@ -715,10 +715,14 @@ type CartExtras = {
|
|
|
715
715
|
currency: string;
|
|
716
716
|
} | null;
|
|
717
717
|
discount?: AppliedDiscount | null;
|
|
718
|
-
/**
|
|
718
|
+
/**
|
|
719
|
+
* The Idempotency-Key of the last checkout attempt, the body it was sent with, and where
|
|
720
|
+
* Meta's pixel ran then, which a retry sends again unchanged.
|
|
721
|
+
*/
|
|
719
722
|
attempt?: {
|
|
720
723
|
key: string;
|
|
721
724
|
body: string;
|
|
725
|
+
meta?: Record<string, string>;
|
|
722
726
|
} | null;
|
|
723
727
|
};
|
|
724
728
|
|
|
@@ -715,10 +715,14 @@ type CartExtras = {
|
|
|
715
715
|
currency: string;
|
|
716
716
|
} | null;
|
|
717
717
|
discount?: AppliedDiscount | null;
|
|
718
|
-
/**
|
|
718
|
+
/**
|
|
719
|
+
* The Idempotency-Key of the last checkout attempt, the body it was sent with, and where
|
|
720
|
+
* Meta's pixel ran then, which a retry sends again unchanged.
|
|
721
|
+
*/
|
|
719
722
|
attempt?: {
|
|
720
723
|
key: string;
|
|
721
724
|
body: string;
|
|
725
|
+
meta?: Record<string, string>;
|
|
722
726
|
} | null;
|
|
723
727
|
};
|
|
724
728
|
|
package/dist/index.cjs
CHANGED
|
@@ -236,6 +236,17 @@ function currentMe() {
|
|
|
236
236
|
return null;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
+
function metaBrowser() {
|
|
240
|
+
const fbp = readCookie("_fbp");
|
|
241
|
+
if (!fbp || typeof window.fbq !== "function") return void 0;
|
|
242
|
+
const fbc = readCookie("_fbc");
|
|
243
|
+
return {
|
|
244
|
+
fbp,
|
|
245
|
+
...fbc ? { fbc } : {},
|
|
246
|
+
client_user_agent: window.navigator.userAgent,
|
|
247
|
+
event_source_url: window.location.origin + window.location.pathname
|
|
248
|
+
};
|
|
249
|
+
}
|
|
239
250
|
function storedCartId() {
|
|
240
251
|
const v = readLocal("cart_id");
|
|
241
252
|
if (!v || v === "undefined" || v === "null") return null;
|
|
@@ -2207,11 +2218,13 @@ var CheckoutService = class extends BaseService {
|
|
|
2207
2218
|
...extra
|
|
2208
2219
|
};
|
|
2209
2220
|
const serialised = JSON.stringify(body);
|
|
2210
|
-
const
|
|
2211
|
-
|
|
2221
|
+
const retry = extras.attempt?.body === `${code}:${serialised}`;
|
|
2222
|
+
const key = retry ? extras.attempt.key : newKey();
|
|
2223
|
+
const meta = retry ? extras.attempt?.meta : metaBrowser();
|
|
2224
|
+
saveCartExtras(id2, { attempt: { key, body: `${code}:${serialised}`, ...meta ? { meta } : {} } });
|
|
2212
2225
|
const result = await this.data(`/api/checkout/${encodeURIComponent(code)}`, {
|
|
2213
2226
|
method: "POST",
|
|
2214
|
-
body,
|
|
2227
|
+
body: meta ? { ...body, metadata: { ...extra.metadata, meta_capi: meta } } : body,
|
|
2215
2228
|
headers: { "Idempotency-Key": key }
|
|
2216
2229
|
});
|
|
2217
2230
|
if (result.order.access_token) {
|
|
@@ -3167,6 +3180,10 @@ var StoreService = class extends BaseService {
|
|
|
3167
3180
|
// The footer's sign-up box posts to ext/newsletter, and the theme editor's footer
|
|
3168
3181
|
// switch (D131) can only show it while that is on.
|
|
3169
3182
|
newsletter: { ...basePlugins.newsletter, ...flag(plugins.has("newsletter")) },
|
|
3183
|
+
// The ad and analytics tags (D160). The engine decides, not the static record:
|
|
3184
|
+
// one storefront serves every store, and one store's pixel must never
|
|
3185
|
+
// load on another's pages.
|
|
3186
|
+
...adTags(plugins),
|
|
3170
3187
|
// Discount codes are core: every GoCommerce store takes them, so
|
|
3171
3188
|
// the code box is shown whatever the static record says.
|
|
3172
3189
|
isDiscountCoupons: { ...basePlugins.isDiscountCoupons, active: true },
|
|
@@ -3192,6 +3209,22 @@ var StoreService = class extends BaseService {
|
|
|
3192
3209
|
}
|
|
3193
3210
|
};
|
|
3194
3211
|
var storeService = new StoreService();
|
|
3212
|
+
var AD_TAGS = [
|
|
3213
|
+
["meta-pixel", "pixel_id", "facebookPixel"],
|
|
3214
|
+
["microsoft-clarity", "project_id", "microsoftClarity"],
|
|
3215
|
+
["hotjar", "site_id", "hotjar"],
|
|
3216
|
+
["tiktok-pixel", "pixel_id", "tiktokPixel"],
|
|
3217
|
+
["pinterest-tag", "tag_id", "pinterestTag"],
|
|
3218
|
+
["snapchat-pixel", "pixel_id", "snapchatPixel"]
|
|
3219
|
+
];
|
|
3220
|
+
function adTags(plugins) {
|
|
3221
|
+
return Object.fromEntries(
|
|
3222
|
+
AD_TAGS.map(([key, field, name]) => {
|
|
3223
|
+
const id2 = String(plugins.get(key)?.settings?.[field] ?? "").trim();
|
|
3224
|
+
return [name, id2 ? { active: true, id: id2 } : { active: false }];
|
|
3225
|
+
})
|
|
3226
|
+
);
|
|
3227
|
+
}
|
|
3195
3228
|
function deliverable(base, ships) {
|
|
3196
3229
|
if (ships.everywhere || !ships.countries.length) return {};
|
|
3197
3230
|
const known = new Map((base.countries ?? []).map((c) => [String(c.code).toUpperCase(), c]));
|