DocsStorefront integrationMultipliers and entry estimates

Coming soon Kwik's public API and MCP server are coming soon. These docs are an early preview, in the beginning stages: endpoints, fields and examples are samples and will change before launch. Brands on Kwik today can ask their account manager about integrations.

Read every docs page as one Markdown file, ready to paste into ChatGPT, Claude or any AI assistant.

Storefront integration · Guide 4 of 4

Show Multipliers And Estimate Entries.

Show the right multiplier on product cards and product pages, then estimate a cart's entries the way Kwik counts them.

Before you start

  • The shared clock from the timer guide, so badges, timers and cart estimates use the same promotion.
  • Each product's numeric id, tags and collection titles available to your script.
  • The share-link cookie from the first guide, for referral multipliers.

The data

The shop metafield giveaway_entries has one object per running giveaway: this week's base rate and its multipliers. The example uses one entry per dollar.

JSON · giveaway_entries (example)
[
  {
    "geId": 11,
    "geName": "Truck Giveaway",
    "forEachAmt": null,
    "forEachPct": 100,
    "pointValue": 1,
    "multipliers": [
      { "multiplierType": "purchase_multiplier", "forEachAmt": 5, "shopifyProductIds": [8100000000001],
        "stkAny": false, "stkRefMulti": false, "stkMulRef": false },
      { "multiplierType": "site_wide_multiplier", "forEachAmt": 2 },
      { "multiplierType": "order_multiplier", "forEachAmt": 2, "shopifyProductIds": [8100000000001, 8100000000002],
        "stkAny": false, "stkRefMulti": false, "stkMulRef": false },
      { "multiplierType": "referral_multiplier", "forEachAmt": 3 }
    ]
  }
]
FieldWhat it means
forEachPct and pointValueThe base rate. Entries per $1 = forEachPct / 100 × pointValue. 100 and 1 means 1 entry per dollar.
forEachAmt (on the giveaway)A flat number of entries per item instead of per dollar. When it is set, don't show an "NX" label.
forEachAmt (on a multiplier)The multiplier itself: 5 means 5×. It is not a base rate.
multiplierTypepurchase_multiplier (product), site_wide_multiplier, order_multiplier or referral_multiplier.
shopifyProductIdsThe products it applies to. An empty list matches nothing. On very large catalogs it can be left out, and values holds tag names (multiOn 1) or collection titles (multiOn 3).
stkAny, stkRefMulti, stkMulRefWho gets it, not how it stacks. None set: the buyer. stkRefMulti: the buyer on a referred order. stkMulRef: the referrer only, never show it to the buyer. stkAny: both.

The calculation, in Kwik's order

  1. Base: each eligible line's amount paid × the base rate.
  2. Product or sitewide: apply the product's multiplier when one matches. Otherwise use the active sitewide multiplier. They never stack. If two multipliers of the same type match, the higher one counts.
  3. Order and referral: add up the lines, then apply the order multiplier and the referral multiplier. The referral multiplier only counts when the shopper came in on a share link.
  4. Fixed bonus entries last. They are never multiplied.

Worked example

StepHoodie, $40Cap, $20Cart
1. Base at 1 entry per $14020
2. Product 5×, or sitewide 2×40 × 5 = 20020 × 2 = 40240
3a. Order multiplier 2×240 × 2 = 480
3b. Referral multiplier 3×480 × 3 = 1,440
4. Fixed bonus1,440 + 100 = 1,540

Kwik rounds once, at the end, and applies an order multiplier only to the products it lists. When it lists every product in the cart, as here, that is the same as multiplying the cart total.

JavaScript · kwik-entries.js
// kwik-entries.js: multiplier badges and cart estimates from giveaway_entries.
// "product" is {id, tags, collections}: numeric Shopify product id, tag names, collection titles.

const num = (v) => (Number.isFinite(Number(v)) ? Number(v) : 0);
const isFlat = (rate) => num(rate?.forEachAmt) > 0;

// Entries per $1 at the base rate. forEachPct 100 with pointValue 1 = 1 entry per dollar.
export function perDollar(rate) {
  return (num(rate.forEachPct) / 100) * (rate.pointValue == null ? 1 : num(rate.pointValue));
}

// The flags say WHO gets a multiplier. Never show a referrer-only multiplier to the buyer.
function buyerGets(m, hasWaveLink) {
  if (m.multiplierType === 'referral_multiplier') return hasWaveLink;
  if (m.multiplierType === 'site_wide_multiplier') return true;
  if (m.stkAny) return true;
  if (m.stkRefMulti) return hasWaveLink;
  if (m.stkMulRef) return false;
  return true;
}

function matches(m, product) {
  if (String(m.multiOn) === '5') return false;            // promo-code multipliers: not shown on the storefront
  if (Array.isArray(m.shopifyProductIds)) return m.shopifyProductIds.some((id) => String(id) === String(product.id));
  const values = (m.values ?? []).map((v) => String(v).toLowerCase());
  const pool = String(m.multiOn) === '1' ? product.tags ?? [] : String(m.multiOn) === '3' ? product.collections ?? [] : [];
  return pool.some((v) => values.includes(String(v).toLowerCase()));
}

function best(rate, type, hasWaveLink, product) {
  const factors = (rate.multipliers ?? [])
    .filter((m) => m.multiplierType === type && num(m.forEachAmt) > 0 && buyerGets(m, hasWaveLink))
    .filter((m) => !product || matches(m, product))
    .map((m) => num(m.forEachAmt));
  return factors.length ? Math.max(...factors) : 0;        // same type twice: the highest wins
}

// Step 2: a product multiplier replaces the sitewide one. They never stack.
export function productOrSitewide(rate, product, hasWaveLink = false) {
  return best(rate, 'purchase_multiplier', hasWaveLink, product) || best(rate, 'site_wide_multiplier', hasWaveLink) || 1;
}

export function estimateCart(lines, rate, {hasWaveLink = false, fixedBonus = 0} = {}) {
  if (!rate) return null;                                   // between offers: no rate, no estimate
  const rows = lines.map((line) => {
    // Step 1: amount paid x base rate (or a flat amount per item)
    const base = isFlat(rate) ? num(rate.forEachAmt) * line.quantity : line.amountPaid * perDollar(rate);
    // Step 2: product multiplier, or the sitewide multiplier
    const factor = productOrSitewide(rate, line.product, hasWaveLink);
    const order = best(rate, 'order_multiplier', hasWaveLink, line.product) || 1;
    return {title: line.title, base, factor, order, entries: base * factor};
  });
  // Step 3: sum the lines, then the order multiplier and the referral multiplier
  const lineTotal = rows.reduce((t, r) => t + r.entries, 0);
  const afterOrder = rows.reduce((t, r) => t + r.entries * r.order, 0);
  const referral = best(rate, 'referral_multiplier', hasWaveLink) || 1;
  const multiplied = Math.round(afterOrder * referral);    // round once
  // Step 4: fixed bonus entries last. They are never multiplied.
  return {rows, lineTotal, afterOrder, referral, multiplied, fixedBonus, total: multiplied + fixedBonus};
}
JavaScript · the worked example as a test
// The worked example as a test (Vitest or Jest).
import {estimateCart} from './kwik-entries.js';
import rateList from './fixtures/giveaway_entries.json';   // the JSON above

const hoodie = {id: 8100000000001, tags: [], collections: []};
const cap = {id: 8100000000002, tags: [], collections: []};

test('worked example: 1,540 entries', () => {
  const est = estimateCart(
    [
      {title: 'Hoodie', amountPaid: 40, quantity: 1, product: hoodie},
      {title: 'Cap', amountPaid: 20, quantity: 1, product: cap},
    ],
    rateList[0],
    {hasWaveLink: true, fixedBonus: 100},
  );
  expect(est.rows.map((r) => r.entries)).toEqual([200, 40]);   // 40 x 1 x 5, 20 x 1 x 2
  expect(est.lineTotal).toBe(240);
  expect(est.afterOrder).toBe(480);                              // x2 order multiplier
  expect(est.multiplied).toBe(1440);                             // x3 referral multiplier
  expect(est.total).toBe(1540);                                  // + 100 fixed bonus
});

test('no referral link: no referral multiplier', () => {
  const est = estimateCart([{title: 'Hoodie', amountPaid: 40, quantity: 1, product: hoodie}], rateList[0]);
  expect(est.total).toBe(400);                                   // 40 x 5 x 2
});

Any website: kwik-entries.js is plain JavaScript with no Shopify code in it. Give it the giveaway's rate and multipliers in the shape above, from Shopify metafields or your own server, and your cart lines as {title, amountPaid, quantity, product: {id, tags, collections}}.

Needs confirmationFixed bonus entries, like sign-up, free or promo-code entries, are not in the storefront data. Pass a known amount as fixedBonus or leave it at 0. Promo-code multipliers (multiOn 5) can't be shown before checkout.

Badges on product cards and pages

A badge shows the product's multiplier and what it earns at full price: "5× · Earn 200 entries". Use the product multiplier when one matches, otherwise the sitewide one. Hide the badge between offers, while the clock is reloading, and, when wavelink_required is true, for shoppers who didn't come in on a share link.

Liquid theme · product card badge
<!-- In your product card snippet. Liquid prices are in cents. -->
<span class="kwik-badge" hidden
  data-kwik-badge
  data-product-id="{{ card_product.id }}"
  data-price="{{ card_product.price }}"
  data-tags="{{ card_product.tags | join: '|' | escape }}"
  data-collections="{{ card_product.collections | map: 'title' | join: '|' | escape }}"></span>

<!-- Once per page, after kwik-promo.js -->
<script type="module">
  import {perDollar, productOrSitewide} from '{{ "kwik-entries.js" | asset_url }}';
  const hasWaveLink = /(?:^|;\s*)_kwik_waveLink=[A-Za-z0-9]{1,64}/.test(document.cookie);

  window.kwikPromo.subscribe(({rate, updating}) => {
    document.querySelectorAll('[data-kwik-badge]').forEach((el) => {
      if (!rate || updating) return (el.hidden = true);          // between offers or refreshing: hide
      const product = {
        id: el.dataset.productId,
        tags: el.dataset.tags.split('|').filter(Boolean),
        collections: el.dataset.collections.split('|').filter(Boolean),
      };
      const factor = productOrSitewide(rate, product, hasWaveLink);
      const base = Number(rate.forEachAmt) > 0 ? Number(rate.forEachAmt) : (Number(el.dataset.price) / 100) * perDollar(rate);
      const entries = Math.round(base * factor);
      el.textContent = `${factor > 1 ? factor + '× · ' : ''}Earn ${entries.toLocaleString('en-US')} entries`;
      el.hidden = false;
    });
  });
</script>

Always pass the product, never just a price. Tag and collection multipliers can only match when the script knows the product's tags and collections. Shopify's /cart.js doesn't include them, so print them in Liquid for cart lines too.

25 entries per dollar is not the same as 25×

LabelWhat it means$40 hoodie
"25 entries per $1"The base rate: forEachPct 2500, pointValue 11,000 entries
"25×" at a base of 1 per $1A multiplier on the base rate1,000 entries
"25×" at a base of 2 per $1Same multiplier, different base2,000 entries

The two only match when the base is 1 entry per dollar. Kwik's own timer text often says "30X" for a 30-per-dollar week. In your own copy, say "per $1" for a rate and "×" for a multiplier, and show the entries it earns.

Theme tags like kwik10

Older themes set multipliers with product tags. Kwik data now comes first. Keep tags only as a fallback for stores that aren't on Kwik 2.0 yet, then remove them.

TagOld meaning
kwik10A tag containing "kwik" plus a number sets that product's multiplier: 10×. The last matching tag wins.
bonus:100Adds 100 flat bonus entries to that product.
  • The old theme math was ceil(price) × N: price rounded up to the dollar, then multiplied. Kwik's math rounds once, at the end, so the two can differ by a few entries.
  • Don't fall back to tags between weeks. Kwik awards nothing then, so tag numbers would over-promise.
  • Never show both a tag badge and a Kwik badge on the same card.

Keep the bar, badges and cart in sync

Subscribe every display to the same shared clock. When the 50× week ends, one event updates all three together:

DisplayBefore midnightAfter midnight
Announcement bar"50X Ends Tonight", counting down"25X Through Sunday", counting to Monday 12:00 AM
Product badge on a $40 hoodie"Earn 2,000 entries" (50 per $1)Hidden for a moment, then "Earn 1,000 entries" (25 per $1)
Cart estimateAt the 50× rateRecalculated at the 25× rate

Never compute a display from its own copy of the data or its own timer. That is how a bar ends up saying 25× while a badge still says 50×.

Compare the estimate with what Kwik records

  • After a test order, check the entries on the Kwik thank-you page block or the Point Tracker block (with Show set to include giveaway entries), or the customer's entries in the Kwik admin.
  • Expect small differences from rounding, promo-code multipliers, products the giveaway excludes, and refunds.
  • A big difference usually means the product's tags or collections weren't passed, so a product multiplier didn't match.
  • The API preview has GET /giveaways/{giveaway_id}/customers/{customer_id} for this. It is a preview, not live yet.

Customer entry balances ("you have 4,200 entries") are not in the storefront data. Use the native Point Tracker, Points Overview or Loyalty popup blocks for those.

End-to-end test

  1. On a test store, set the example up in Kwik: 1 entry per $1, the hoodie at 5×, sitewide 2×, order 2× on both products, referral 3×.
  2. Open /products/hoodie?waveLink=ABC123. The hoodie badge shows "5×" and the cap badge "2×".
  3. Add both to the cart. The estimate reads 1,540 when you pass a 100-entry bonus, or 1,440 without it.
  4. Repeat in a new private window without the share link. The estimate drops to 480, because the referral multiplier no longer applies.
  5. Place the referred order with a test payment and compare the entries Kwik records with the estimate.