{"title":"Set","description":"\n\u003c!-- ===== Merlin Classics: Auto-generated Set Buttons ===== --\u003e\n\n\u003cstyle\u003e\n\/* Responsive button layout (wraps across page) *\/\n.mrc-set-wrap {\n  display: flex;\n  flex-wrap: wrap;\n  gap: 10px;\n  align-items: stretch;\n  margin: 10px 0 12px;\n}\n\n\/*\n  Match your paragraph:\n    \u003cp style=\"... font-size:0.75em;\"\u003e\n  So we use font-size:0.75em and color:inherit.\n  Bold: font-weight:700.\n*\/\n.mrc-set-btn {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n\n  padding: 10px 14px;\n  min-height: 44px;\n\n  background: #fff;\n  color: inherit;\n\n  border: 2px solid currentColor;\n  border-radius: 0;\n\n  cursor: pointer;\n\n  font-family: inherit;\n  font-size: 0.75em;\n  font-weight: 700;\n  line-height: 1.1;\n\n  white-space: nowrap;\n  text-align: center;\n}\n\n.mrc-set-btn:hover {\n  background: rgba(0,0,0,0.03);\n}\n\n.mrc-set-btn:disabled {\n  opacity: 0.6;\n  cursor: not-allowed;\n}\n\u003c\/style\u003e\n\n\u003cdiv class=\"mrc-set-wrap\" id=\"mrc-set-wrap\"\u003e\n  \u003cbutton type=\"button\" class=\"mrc-set-btn\" id=\"mrc_set_btn_1\"\u003eBuy Set of 12 - All Animal Year 11oz Mugs (2 Free)\u003c\/button\u003e \u003cbutton type=\"button\" class=\"mrc-set-btn\" id=\"mrc_set_btn_2\"\u003eBuy Set of 6 - Recent Animal Year 11oz Mugs (1 Free)\u003c\/button\u003e \u003cbutton type=\"button\" class=\"mrc-set-btn\" id=\"mrc_set_btn_3\"\u003eBuy Set of 3 - Recent Animal Year 11oz Mugs\u003c\/button\u003e \u003cbutton type=\"button\" class=\"mrc-set-btn\" id=\"mrc_set_btn_4\"\u003eBuy 1 Current Year of the Horse (2026) 11oz Mug\u003c\/button\u003e\n\u003c\/div\u003e\n\n\u003cscript\u003e\n(function() {\n  \/\/ IDs are STRINGS to avoid JS integer precision issues\n  var SET_BUTTONS = {\"mrc_set_btn_1\": {\"name\": \"Buy Set of 12 - All Animal Year Mugs (2 Free)\", \"ids\": [\"47622014009561\", \"47622014959833\", \"47622016401625\", \"47622017089753\", \"47622018171097\", \"47621993332953\", \"47621999722713\", \"47622012371161\", \"47622012502233\", \"47622013452505\", \"47621998411993\", \"47621997363417\"]}, \"mrc_set_btn_2\": {\"name\": \"Buy Set of 6 - Recent Animal Year Mugs (1 Free)\", \"ids\": [\"47621999722713\", \"47622012371161\", \"47622012502233\", \"47622013452505\", \"47621998411993\", \"47621997363417\"]}, \"mrc_set_btn_3\": {\"name\": \"Buy Set of 3 - Recent Animal Year Mugs\", \"ids\": [\"47622013452505\", \"47621998411993\"]}, \"mrc_set_btn_4\": {\"name\": \"Buy 1 Current Year of the Horse (2026) Mug\", \"ids\": [\"47621997363417\"]}};\n\n  function fetchVariantJson(variantId) {\n    return fetch(\"\/variants\/\" + encodeURIComponent(variantId) + \".js\", {\n      method: \"GET\",\n      headers: { \"Accept\": \"application\/json\" }\n    })\n    .then(function(res) {\n      if (!res.ok) {\n        return { ok: false, available: false, status: res.status };\n      }\n      return res.json().then(function(data) {\n        return {\n          ok: true,\n          available: !!data.available,\n          status: res.status\n        };\n      });\n    })\n    .catch(function() {\n      return { ok: false, available: false, status: 0 };\n    });\n  }\n\n  function addItemsToCart(ids) {\n    var items = ids.map(function(id) {\n      return { id: id, quantity: 1 };\n    });\n\n    return fetch(\"\/cart\/add.js\", {\n      method: \"POST\",\n      headers: {\n        \"Content-Type\": \"application\/json\",\n        \"Accept\": \"application\/json\"\n      },\n      body: JSON.stringify({ items: items })\n    });\n  }\n\n  function normalizeButtonWidths() {\n    var buttons = document.querySelectorAll('.mrc-set-btn');\n    if (!buttons.length) return;\n\n    buttons.forEach(function(btn) {\n      btn.style.width = 'auto';\n    });\n\n    var maxWidth = 0;\n    buttons.forEach(function(btn) {\n      var w = btn.getBoundingClientRect().width;\n      if (w \u003e maxWidth) maxWidth = w;\n    });\n\n    buttons.forEach(function(btn) {\n      btn.style.width = Math.ceil(maxWidth) + 'px';\n    });\n  }\n\n  function scheduleNormalize() {\n    window.requestAnimationFrame(normalizeButtonWidths);\n  }\n\n  function wireButton(btnId, def) {\n    var btn = document.getElementById(btnId);\n    if (!btn) return;\n\n    btn.addEventListener(\"click\", function() {\n      var originalText = btn.textContent;\n      btn.disabled = true;\n      btn.textContent = \"Checking…\";\n      scheduleNormalize();\n\n      var ids = def.ids || [];\n\n      Promise.all(ids.map(function(id) {\n        return fetchVariantJson(id).then(function(vinfo) {\n          return { id: id, ok: vinfo.ok, available: vinfo.available, status: vinfo.status };\n        });\n      }))\n      .then(function(checks) {\n        var missing = checks.filter(function(c) { return !c.ok; }).map(function(c) { return c.id; });\n        var unavailable = checks.filter(function(c) { return c.ok \u0026\u0026 !c.available; }).map(function(c) { return c.id; });\n\n        if (missing.length || unavailable.length) {\n          var msg = \"Did not add \\\"\" + def.name + \"\\\".\\n\\n\";\n          if (missing.length) msg += \"Missing\/not published: \" + missing.join(\", \") + \"\\n\\n\";\n          if (unavailable.length) msg += \"Unavailable: \" + unavailable.join(\", \");\n          alert(msg);\n\n          btn.disabled = false;\n          btn.textContent = originalText;\n          scheduleNormalize();\n          return;\n        }\n\n        btn.textContent = \"Adding…\";\n        scheduleNormalize();\n\n        return addItemsToCart(ids).then(function(res) {\n          if (!res.ok) {\n            return res.text().then(function(t) { throw new Error(t || \"Add failed\"); });\n          }\n          window.location.href = '\/cart';\n        });\n      })\n      .catch(function(err) {\n        console.error(err);\n        alert(\"Sorry — could not add \\\"\" + def.name + \"\\\" to cart.\");\n        btn.disabled = false;\n        btn.textContent = originalText;\n        scheduleNormalize();\n      });\n    });\n  }\n\n  Object.keys(SET_BUTTONS).forEach(function(btnId) {\n    wireButton(btnId, SET_BUTTONS[btnId]);\n  });\n\n  \/\/ Normalize widths after render + after fonts load + on resize\n  scheduleNormalize();\n  if (document.fonts \u0026\u0026 document.fonts.ready) {\n    document.fonts.ready.then(scheduleNormalize);\n  }\n  window.addEventListener('resize', scheduleNormalize);\n\n  var wrap = document.getElementById('mrc-set-wrap');\n  if (wrap \u0026\u0026 'ResizeObserver' in window) {\n    var ro = new ResizeObserver(function() {\n      scheduleNormalize();\n    });\n    ro.observe(wrap);\n  }\n})();\n\u003c\/script\u003e\n\n\u003c!-- ===== End Auto-generated Set Buttons ===== --\u003e","products":[],"url":"https:\/\/merlinclassics.store\/collections\/set.oembed","provider":"Merlin Classics","version":"1.0","type":"link"}