← back to Dw Signup Fulfillment
auto-save: 2026-07-28T11:30:09 (1 files) — lib/shopify.js
4a5a68352b7c6833811aec8f12cc8ff14c3b9b5b · 2026-07-28 11:30:10 -0700 · Steve Abrams
Files touched
Diff
commit 4a5a68352b7c6833811aec8f12cc8ff14c3b9b5b
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Tue Jul 28 11:30:10 2026 -0700
auto-save: 2026-07-28T11:30:09 (1 files) — lib/shopify.js
---
lib/shopify.js | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/lib/shopify.js b/lib/shopify.js
index 2ef5309..a8196c2 100644
--- a/lib/shopify.js
+++ b/lib/shopify.js
@@ -112,6 +112,15 @@ async function addTags(customerId, newTags) {
return updateCustomer(customerId, { tags: merged });
}
+// Read one customer metafield value (namespace.key), or null. Used for the
+// welcome-gift idempotency flag. GET → allowed in DRY_RUN (with a real token).
+async function getCustomerMetafield(customerId, namespace, key) {
+ const r = await request('GET', `/customers/${customerId}/metafields.json?namespace=${encodeURIComponent(namespace)}`, undefined);
+ const mfs = r && r.json && Array.isArray(r.json.metafields) ? r.json.metafields : [];
+ const m = mfs.find(x => x.key === key && x.namespace === namespace);
+ return m ? m.value : null;
+}
+
// Set a customer metafield (e.g. custom.assigned_rep).
async function setCustomerMetafield(customerId, { namespace, key, value, type }) {
return request('POST', `/customers/${customerId}/metafields.json`, {
@@ -173,6 +182,6 @@ async function graphql(query, variables, opts = {}) {
}
module.exports = {
- request, graphql, createGiftCard, updateCustomer, getCustomer, findCustomerByEmail, addTags,
+ request, graphql, createGiftCard, updateCustomer, getCustomer, getCustomerMetafield, findCustomerByEmail, addTags,
setCustomerMetafield, createWebhook, base,
};
← 766b6b6 hosting: live on Kamatera dwsignup.agentabrams.com (pm2 :986
·
back to Dw Signup Fulfillment
·
webhook: secret-less re-fetch auth (Steve's choice) — re-fet d3d9b16 →