← back to Dw Signup Fulfillment
verification/tk10836/verify-kelly.js
40 lines
#!/usr/bin/env node
'use strict';
// READ-ONLY verification for TK-10836: is Kelly's 3-free-sample honor actually live?
const config = require('../../lib/config');
const shop = config.SHOP_DOMAIN;
const token = config.SHOPIFY_FULFILLMENT_TOKEN;
console.log('shop=', shop, 'token_last4=', token ? String(token).slice(-4) : 'MISSING');
console.log('RETAIL_SHARED_CODE set?', !!config.RETAIL_SHARED_CODE);
async function gql(query, variables) {
const r = await fetch(`https://${shop}/admin/api/2024-10/graphql.json`, {
method: 'POST',
headers: { 'X-Shopify-Access-Token': token, 'Content-Type': 'application/json' },
body: JSON.stringify({ query, variables }),
});
const j = await r.json();
if (j.errors) console.error('GQL errors:', JSON.stringify(j.errors));
return j.data;
}
(async () => {
// 1. Kelly's customer record + tags
const cust = await gql(`query($id:ID!){ customer(id:$id){ id email firstName lastName tags createdAt } }`,
{ id: 'gid://shopify/Customer/8388564123699' });
console.log('\n=== KELLY CUSTOMER ===');
console.log(JSON.stringify(cust, null, 2));
// 2. The 3FREE discount code — active? usable?
const disc = await gql(`query{ codeDiscountNodes(first:10, query:"code:3FREE"){ nodes { id codeDiscount {
__typename
... on DiscountCodeBasic { title status startsAt endsAt appliesOncePerCustomer usageLimit asyncUsageCount
customerSelection { __typename }
codes(first:5){ nodes { code } }
customerGets { value { __typename ... on DiscountAmount { amount { amount currencyCode } appliesOnEachItem } } }
}
} } } }`);
console.log('\n=== 3FREE DISCOUNT ===');
console.log(JSON.stringify(disc, null, 2));
})().catch(e => { console.error('ERR', e.message); process.exit(1); });