{"id":10562,"date":"2026-01-19T13:39:31","date_gmt":"2026-01-19T04:39:31","guid":{"rendered":"https:\/\/code-plus.jp\/gp\/?p=10562"},"modified":"2026-06-04T00:04:26","modified_gmt":"2026-06-03T15:04:26","slug":"shopify-popup-10562","status":"publish","type":"post","link":"https:\/\/code-plus.jp\/gp\/shopify-popup-10562\/","title":{"rendered":"Shopify\u3067\u5546\u54c1\u30ab\u30fc\u30c8\u8ffd\u52a0\u6642\u306b\u78ba\u8a8d\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u3092\u8868\u793a\u3059\u308b\u65b9\u6cd5\u3010Liquid\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3011"},"content":{"rendered":"<p>EC\u30b5\u30a4\u30c8\u3092\u904b\u55b6\u3057\u3066\u3044\u308b\u3068\u3001\u300c\u3053\u306e\u5546\u54c1\u306f\u5358\u4f53\u3067\u306f\u4f7f\u3048\u307e\u305b\u3093\u300d\u300c\u5225\u306e\u5546\u54c1\u3068\u4e00\u7dd2\u306b\u8cfc\u5165\u3057\u3066\u304f\u3060\u3055\u3044\u300d\u3068\u3044\u3063\u305f\u6ce8\u610f\u4e8b\u9805\u3092\u304a\u5ba2\u69d8\u306b\u4f1d\u3048\u305f\u3044\u5834\u9762\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\r\n<p>\u4f8b\u3048\u3070\uff1a<\/p>\r\n<ul class=\"my-0.5r\" style=\"list-style-type:bullet;\">\r\n<li>\u30d7\u30ea\u30f3\u30bf\u30fc\u306e<b class=\"bold\">\u30a4\u30f3\u30af\u30ab\u30fc\u30c8\u30ea\u30c3\u30b8<\/b>\uff08\u5bfe\u5fdc\u6a5f\u7a2e\u306e\u78ba\u8a8d\uff09<\/li>\r\n<li>\u6d44\u6c34\u5668\u306e<b class=\"bold\">\u4ea4\u63db\u7528\u30ab\u30fc\u30c8\u30ea\u30c3\u30b8<\/b>\uff08\u672c\u4f53\u306e\u30b9\u30d1\u30a6\u30c8\u304c\u5fc5\u8981\uff09<\/li>\r\n<li>\u30b9\u30de\u30db\u306e<b class=\"bold\">\u30b1\u30fc\u30b9<\/b>\uff08\u6a5f\u7a2e\u306e\u78ba\u8a8d\uff09<\/li>\r\n<\/ul>\r\n<p>\u4eca\u56de\u306f\u3001<b class=\"bold\">\u30a2\u30d7\u30ea\u4e0d\u8981\u30fb\u7121\u6599<\/b>\u3067\u3001Liquid\u30c6\u30fc\u30de\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3060\u3051\u3067\u78ba\u8a8d\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u3092\u5b9f\u88c5\u3059\u308b\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\r\n\r\n <!-- \u2605\u76ee\u6b21\u30ea\u30b9\u30c8 -->\r\n<ul class=\"tocList mt-1r\" data-toc-id=\"js-tocBWGD\" style=\"height:28rem\"><\/ul>\r\n<ins class=\"tocBtn is-fixed\" data-toc-id=\"js-tocBWGD\"><\/ins>\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<hr class=\"rule-hory mt-3r\">\r\n<h2 class=\"fz-xl\">\u5b8c\u6210\u30a4\u30e1\u30fc\u30b8<\/h2>\r\n<p>\u5b9f\u88c5\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u52d5\u4f5c\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\r\n<pre><code class=\"language-\">1. \u304a\u5ba2\u69d8\u304c\u300c\u30ab\u30fc\u30c8\u306b\u8ffd\u52a0\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\r\n      \u2193\r\n2. \u78ba\u8a8d\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u304c\u8868\u793a\u3055\u308c\u308b\r\n      \u2193\r\n3-A.\u300c\u306f\u3044\u300d\u2192 \u30ab\u30fc\u30c8\u306b\u5546\u54c1\u304c\u8ffd\u52a0\u3055\u308c\u308b\r\n3-B.\u300c\u672c\u4f53\u30da\u30fc\u30b8\u3092\u898b\u308b\u300d\u2192 \u5225\u306e\u5546\u54c1\u30da\u30fc\u30b8\u3078\u9077\u79fb\r\n<\/code><\/pre>\r\n<h3 class=\"fz-ml\">\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u6a5f\u80fd<\/h3>\r\n<ul class=\"my-0.5r\" style=\"list-style-type:bullet;\">\r\n<li>\u7279\u5b9a\u306e\u5546\u54c1\u30da\u30fc\u30b8\u3067\u306e\u307f\u8868\u793a<\/li>\r\n<li>\u300c\u306f\u3044\u300d\u3067\u30ab\u30fc\u30c8\u8ffd\u52a0\u3092\u5b9f\u884c<\/li>\r\n<li>\u300c\u672c\u4f53\u30da\u30fc\u30b8\u3092\u898b\u308b\u300d\u3067\u5225\u30da\u30fc\u30b8\u3078\u9077\u79fb<\/li>\r\n<li>\u300c\u4eca\u5f8c\u3053\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3057\u306a\u3044\u300d\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\uff08localStorage\u4f7f\u7528\uff09<\/li>\r\n<li>ESC\u30ad\u30fc\u3067\u9589\u3058\u308b<\/li>\r\n<li>\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u80cc\u666f\u30af\u30ea\u30c3\u30af\u3067\u9589\u3058\u308b<\/li>\r\n<li>\u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u5bfe\u5fdc\uff08\u30e2\u30d0\u30a4\u30eb\u5bfe\u5fdc\uff09<\/li>\r\n<\/ul>\r\n<hr class=\"rule-hory mt-3r\">\r\n<h2 class=\"fz-xl\">\u5b9f\u88c5\u624b\u9806<\/h2>\r\n<h3 class=\"fz-ml\">\u624b\u98061: \u30c6\u30fc\u30de\u306e\u30b3\u30fc\u30c9\u7de8\u96c6\u753b\u9762\u3092\u958b\u304f<\/h3>\r\n<ol style=\"list-style-type:decimal;\">\r\n<li>Shopify\u7ba1\u7406\u753b\u9762\u306b\u30ed\u30b0\u30a4\u30f3<\/li>\r\n<li>\u5de6\u30e1\u30cb\u30e5\u30fc\u300c\u30aa\u30f3\u30e9\u30a4\u30f3\u30b9\u30c8\u30a2\u300d\u2192\u300c\u30c6\u30fc\u30de\u300d<\/li>\r\n<li>\u73fe\u5728\u306e\u30c6\u30fc\u30de\u306e\u300c<b class=\"bold\">\u2026<\/b>\u300d\u3092\u30af\u30ea\u30c3\u30af<\/li>\r\n<li>\u300c<b class=\"bold\">\u30b3\u30fc\u30c9\u3092\u7de8\u96c6<\/b>\u300d\u3092\u9078\u629e<\/li>\r\n<\/ol>\r\n<h3 class=\"fz-ml\">\u624b\u98062: snippet\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210<\/h3>\r\n<ol style=\"list-style-type:decimal;\">\r\n<li>\u5de6\u30b5\u30a4\u30c9\u30d0\u30fc\u306e\u300c<b class=\"bold\">snippets<\/b>\u300d\u30d5\u30a9\u30eb\u30c0\u3092\u958b\u304f<\/li>\r\n<li>\u300c<b class=\"bold\">\u65b0\u3057\u3044snippet\u3092\u8ffd\u52a0<\/b>\u300d\u3092\u30af\u30ea\u30c3\u30af<\/li>\r\n<li>\u30d5\u30a1\u30a4\u30eb\u540d\u3092 <code>popup-caution<\/code> \u3068\u5165\u529b\uff08\u62e1\u5f35\u5b50.liquid\u306f\u81ea\u52d5\u4ed8\u4e0e\uff09<\/li>\r\n<li>\u300c\u4f5c\u6210\u300d\u3092\u30af\u30ea\u30c3\u30af<\/li>\r\n<\/ol>\r\n<h3 class=\"fz-ml\">\u624b\u98063: \u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u30b3\u30fc\u30c9\u3092\u8cbc\u308a\u4ed8\u3051<\/h3>\r\n<p>\u4f5c\u6210\u3057\u305f <code>popup-caution.liquid<\/code> \u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8cbc\u308a\u4ed8\u3051\u307e\u3059\u3002<\/p>\r\n<pre><code class=\"language-liquid\">{% comment %}\r\n  \u30ab\u30fc\u30c8\u30ea\u30c3\u30b8\u5546\u54c1\u7528 \u78ba\u8a8d\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\r\n  - \u300c\u672c\u4f53\u30da\u30fc\u30b8\u3092\u898b\u308b\u300d\u2192 \u672c\u4f53\u30da\u30fc\u30b8\u3078\u9077\u79fb\r\n  - \u300c\u4eca\u5f8c\u3053\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3057\u306a\u3044\u300d\u30c1\u30a7\u30c3\u30af\u3067\u6b21\u56de\u4ee5\u964d\u30b9\u30ad\u30c3\u30d7\r\n  - ESC\u30ad\u30fc\u3067\u9589\u3058\u308b\r\n{% endcomment %}\r\n\r\n&lt;style&gt;\r\n.caution-popup-overlay {\r\n\tposition: fixed;\r\n\tinset: 0;\r\n\tdisplay: none;\r\n\topacity: 0;\r\n\tpointer-events: none;\r\n\ttransition: opacity 0.3s ease;\r\n\tz-index: 999999;\r\n\tbackground: rgba(0, 0, 0, 0.5);\r\n}\r\n\r\n.caution-popup-overlay.is-open {\r\n\tdisplay: block;\r\n\topacity: 1;\r\n\tpointer-events: auto;\r\n}\r\n\r\n.caution-popup-container {\r\n\tposition: absolute;\r\n\ttop: 50%;\r\n\tleft: 50%;\r\n\ttransform: translate(-50%, -50%);\r\n\tmax-width: 90%;\r\n\tbackground: #fff;\r\n\tborder-radius: 0.5rem;\r\n\t\/* padding  \u4e0a  \u6a2a  \u4e0b *\/\r\n\tpadding: 3rem 3rem 2rem;\r\n\ttext-align: center;\r\n\tbox-shadow: 0 0.75rem 1.875rem rgba(0, 0, 0, 0.2);\r\n}\r\n\r\n.caution-popup-close {\r\n\tposition: absolute;\r\n\ttop: 0.25rem;\r\n\tright: 0.5rem;\r\n\tfont-size: 2rem;\r\n\tbackground: none;\r\n\tcolor: #666;\r\n\tborder: none;\r\n\tcursor: pointer;\r\n}\r\n\r\n.caution-popup-close:hover {\r\n\tcolor: #000;\r\n}\r\n\r\n.caution-popup-title {\r\n\tfont-size: 1.5rem;\r\n\tfont-weight: bold;\r\n\tcolor: #333;\r\n\tmargin-bottom: 1rem;\r\n}\r\n\r\n.caution-popup-content {\r\n\tfont-size: 1rem;\r\n\tcolor: #666;\r\n\tmargin-bottom: 1.5rem;\r\n\tline-height: 1.6;\r\n}\r\n\r\n.caution-popup-buttons {\r\n\tdisplay: flex;\r\n\tjustify-content: center;\r\n\tgap: 1rem;\r\n\tflex-wrap: wrap;\r\n}\r\n\r\n.caution-popup-yes,\r\n.caution-popup-no {\r\n\tcursor: pointer;\r\n\tborder: none;\r\n\tborder-radius: 0.375rem;\r\n\tpadding: 0.8rem 1.5rem;\r\n\tfont-weight: 600;\r\n\tfont-size: 1rem;\r\n\ttransition: all 0.2s ease;\r\n}\r\n\r\n.caution-popup-yes {\r\n\tcolor: #fff;\r\n\tbackground: #333;\r\n}\r\n\r\n.caution-popup-yes:hover {\r\n\tbackground: #555;\r\n}\r\n\r\n.caution-popup-no {\r\n\tcolor: #333;\r\n\tbackground: #ddd;\r\n}\r\n\r\n.caution-popup-no:hover {\r\n\tbackground: #ccc;\r\n}\r\n\r\n\/* \u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9 *\/\r\n.caution-popup-remember {\r\n\tmargin-top: 1.25rem;\r\n}\r\n\r\n.caution-popup-remember-label {\r\n\tdisplay: inline-flex;\r\n\talign-items: center;\r\n\tgap: 0.5rem;\r\n\tcursor: pointer;\r\n\tfont-size: 0.875rem;\r\n\tcolor: #666;\r\n}\r\n\r\n.caution-popup-remember-label input[type=&quot;checkbox&quot;] {\r\n\twidth: 1rem;\r\n\theight: 1rem;\r\n\tcursor: pointer;\r\n}\r\n\r\n@media (max-width: 744px) {\r\n\t.caution-popup-title {\r\n\t\tfont-size: 1.125rem;\r\n\t}\r\n\r\n\t.caution-popup-content {\r\n\t\tfont-size: 0.875rem;\r\n\t}\r\n\r\n\t.caution-popup-yes,\r\n\t.caution-popup-no {\r\n\t\tfont-size: 0.875rem;\r\n\t\tpadding: 0.7rem 1.2rem;\r\n\t}\r\n\r\n\t.caution-popup-remember-label {\r\n\t\tfont-size: 0.8125rem;\r\n\t}\r\n}\r\n&lt;\/style&gt;\r\n\r\n&lt;!-- \u30aa\u30fc\u30d0\u30fc\u30ec\u30a4 --&gt;\r\n&lt;div class=&quot;caution-popup-overlay&quot; id=&quot;caution-popup-overlay&quot;&gt;\r\n  &lt;div class=&quot;caution-popup-container&quot;&gt;\r\n    &lt;button type=&quot;button&quot; class=&quot;caution-popup-close&quot; id=&quot;caution-popup-close&quot; aria-label=&quot;\u9589\u3058\u308b&quot;&gt;\u00d7&lt;\/button&gt;\r\n    &lt;div class=&quot;caution-popup-title&quot;&gt;\u30ab\u30fc\u30c8\u30ea\u30c3\u30b8\u3060\u3051\u3067\u306f\u3054\u5229\u7528\u3067\u304d\u307e\u305b\u3093\u3002&lt;\/div&gt;\r\n    &lt;div class=&quot;caution-popup-content&quot;&gt;\u672c\u4f53\u306f\u304a\u6301\u3061\u3067\u3059\u304b\uff1f&lt;\/div&gt;\r\n    &lt;div class=&quot;caution-popup-buttons&quot;&gt;\r\n      &lt;button type=&quot;button&quot; class=&quot;caution-popup-yes&quot; id=&quot;caution-popup-yes&quot;&gt;\u306f\u3044&lt;\/button&gt;\r\n      &lt;button type=&quot;button&quot; class=&quot;caution-popup-no&quot; id=&quot;caution-popup-no&quot;&gt;\u672c\u4f53\u30da\u30fc\u30b8\u3092\u898b\u308b&lt;\/button&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=&quot;caution-popup-remember&quot;&gt;\r\n      &lt;label class=&quot;caution-popup-remember-label&quot;&gt;\r\n        &lt;input type=&quot;checkbox&quot; id=&quot;caution-popup-remember-checkbox&quot;&gt;\r\n        &lt;span&gt;\u4eca\u5f8c\u3053\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3057\u306a\u3044&lt;\/span&gt;\r\n      &lt;\/label&gt;\r\n    &lt;\/div&gt;\r\n  &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n\r\n&lt;script&gt;\r\n(function() {\r\n  const STORAGE_KEY = &#39;caution_popup_skip&#39;;\r\n  \r\n  \/\/ \u2605 \u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u3092\u8868\u793a\u3059\u308b\u5546\u54c1\u30da\u30fc\u30b8\u306eURL\u306b\u542b\u307e\u308c\u308b\u6587\u5b57\u5217\r\n  \/\/ \u8907\u6570\u6307\u5b9a\u3059\u308b\u5834\u5408\u306f\u914d\u5217\u306b\u8ffd\u52a0\r\n  const TARGET_URL_PATTERNS = [&#39;cartridge&#39;];\r\n  \r\n  \/\/ \u2605 \u300c\u3044\u3044\u3048\u300d\u30dc\u30bf\u30f3\u3067\u9077\u79fb\u3059\u308b\u5148\u306eURL\r\n  const REDIRECT_URL = &#39;\/products\/starterset&#39;;\r\n  \r\n  \/\/ \u5bfe\u8c61\u30da\u30fc\u30b8\u304b\u3069\u3046\u304b\u5224\u5b9a\r\n  function isTargetPage() {\r\n    return TARGET_URL_PATTERNS.some(pattern =&gt; \r\n      window.location.href.includes(pattern)\r\n    );\r\n  }\r\n  \r\n  \/\/ \u5bfe\u8c61\u30da\u30fc\u30b8\u3067\u306a\u3051\u308c\u3070\u4f55\u3082\u3057\u306a\u3044\r\n  if (!isTargetPage()) return;\r\n  \r\n  \/\/ \u300c\u8868\u793a\u3057\u306a\u3044\u300d\u8a2d\u5b9a\u6e08\u307f\u306a\u3089\u30b9\u30ad\u30c3\u30d7\r\n  function shouldSkipPopup() {\r\n    return localStorage.getItem(STORAGE_KEY) === &#39;true&#39;;\r\n  }\r\n\r\n  let currentAtcButton = null;\r\n  const overlay = document.getElementById(&#39;caution-popup-overlay&#39;);\r\n\r\n  function openPopup() {\r\n    overlay.classList.add(&#39;is-open&#39;);\r\n  }\r\n\r\n  function closePopup() {\r\n    overlay.classList.remove(&#39;is-open&#39;);\r\n  }\r\n\r\n  \/\/ \u300c\u306f\u3044\u300d\u30af\u30ea\u30c3\u30af\u6642\u3001\u5b9f\u969b\u306b\u30ab\u30fc\u30c8\u306b\u8ffd\u52a0\r\n  function confirmAddToCart() {\r\n    if (!currentAtcButton) return;\r\n    \r\n    \/\/ \u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u304cON\u306a\u3089\u8a18\u61b6\r\n    const checkbox = document.getElementById(&#39;caution-popup-remember-checkbox&#39;);\r\n    if (checkbox &amp;&amp; checkbox.checked) {\r\n      localStorage.setItem(STORAGE_KEY, &#39;true&#39;);\r\n    }\r\n    \r\n    \/\/ override\u30d5\u30e9\u30b0\u3092\u7acb\u3066\u3066\u518d\u30af\u30ea\u30c3\u30af\r\n    currentAtcButton.dataset.override = &#39;true&#39;;\r\n    currentAtcButton.click();\r\n    currentAtcButton.dataset.override = &#39;&#39;;\r\n    \r\n    currentAtcButton = null;\r\n    closePopup();\r\n  }\r\n\r\n  \/\/ \u30dc\u30bf\u30f3\u306eclick\u30a4\u30d9\u30f3\u30c8\u3092\u30ad\u30e3\u30d7\u30c1\u30e3\u30d5\u30a7\u30fc\u30ba\u3067\u30a4\u30f3\u30bf\u30fc\u30bb\u30d7\u30c8\r\n  document.addEventListener(&#39;click&#39;, function(e) {\r\n    \/\/ \u30b9\u30ad\u30c3\u30d7\u8a2d\u5b9a\u6e08\u307f\u306a\u3089\u4f55\u3082\u3057\u306a\u3044\r\n    if (shouldSkipPopup()) return;\r\n    \r\n    const btn = e.target.closest(&#39;button[type=&quot;submit&quot;], .product-form__submit, [name=&quot;add&quot;]&#39;);\r\n    if (!btn) return;\r\n    \r\n    const form = btn.closest(&#39;form[action*=&quot;\/cart\/add&quot;]&#39;);\r\n    if (!form) return;\r\n\r\n    \/\/ override\u30d5\u30e9\u30b0\u304c\u3042\u308c\u3070\u30b9\u30ad\u30c3\u30d7\uff082\u56de\u76ee\u306e\u30af\u30ea\u30c3\u30af\uff09\r\n    if (btn.dataset.override === &#39;true&#39;) {\r\n      return;\r\n    }\r\n\r\n    \/\/ \u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u3092\u51fa\u3057\u3066\u30ab\u30fc\u30c8\u8ffd\u52a0\u3092\u30d6\u30ed\u30c3\u30af\r\n    e.preventDefault();\r\n    e.stopPropagation();\r\n    e.stopImmediatePropagation();\r\n    \r\n    currentAtcButton = btn;\r\n    openPopup();\r\n  }, true);\r\n\r\n  \/\/ \u30d5\u30a9\u30fc\u30e0\u306esubmit\u3082\u30d6\u30ed\u30c3\u30af\r\n  document.addEventListener(&#39;submit&#39;, function(e) {\r\n    \/\/ \u30b9\u30ad\u30c3\u30d7\u8a2d\u5b9a\u6e08\u307f\u306a\u3089\u4f55\u3082\u3057\u306a\u3044\r\n    if (shouldSkipPopup()) return;\r\n    \r\n    const form = e.target;\r\n    if (!form.action || !form.action.includes(&#39;\/cart\/add&#39;)) return;\r\n    \r\n    const btn = form.querySelector(&#39;button[type=&quot;submit&quot;], .product-form__submit, [name=&quot;add&quot;]&#39;);\r\n    if (btn &amp;&amp; btn.dataset.override === &#39;true&#39;) {\r\n      return;\r\n    }\r\n\r\n    e.preventDefault();\r\n    e.stopPropagation();\r\n    e.stopImmediatePropagation();\r\n  }, true);\r\n\r\n  \/\/ ESC\u30ad\u30fc\u3067\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u3092\u9589\u3058\u308b\r\n  document.addEventListener(&#39;keydown&#39;, function(e) {\r\n    if (e.key === &#39;Escape&#39; &amp;&amp; overlay.classList.contains(&#39;is-open&#39;)) {\r\n      closePopup();\r\n    }\r\n  });\r\n\r\n  \/\/ DOMContentLoaded\u5f8c\u306b\u30dc\u30bf\u30f3\u306e\u30a4\u30d9\u30f3\u30c8\u8a2d\u5b9a\r\n  document.addEventListener(&#39;DOMContentLoaded&#39;, function() {\r\n    document.getElementById(&#39;caution-popup-close&#39;).addEventListener(&#39;click&#39;, closePopup);\r\n    document.getElementById(&#39;caution-popup-yes&#39;).addEventListener(&#39;click&#39;, confirmAddToCart);\r\n    document.getElementById(&#39;caution-popup-no&#39;).addEventListener(&#39;click&#39;, function() {\r\n      window.location.href = REDIRECT_URL;\r\n    });\r\n    overlay.addEventListener(&#39;click&#39;, function(e) {\r\n      if (e.target === overlay) closePopup();\r\n    });\r\n  });\r\n})();\r\n&lt;\/script&gt;\r\n<\/code><\/pre>\r\n<h3 class=\"fz-ml\">\u624b\u98064: theme.liquid\u3067snippet\u3092\u8aad\u307f\u8fbc\u3080<\/h3>\r\n<ol style=\"list-style-type:decimal;\">\r\n<li>\u5de6\u30b5\u30a4\u30c9\u30d0\u30fc\u306e\u300c<b class=\"bold\">Layout<\/b>\u300d\u30d5\u30a9\u30eb\u30c0\u3092\u958b\u304f<\/li>\r\n<li><code>theme.liquid<\/code> \u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u958b\u304f<\/li>\r\n<li><code>&lt;\/body&gt;<\/code> \u30bf\u30b0\u306e<b class=\"bold\">\u76f4\u524d<\/b>\u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\uff1a<\/li>\r\n<\/ol>\r\n<pre><code class=\"language-liquid\">  ...\r\n  {% render &#39;popup-caution&#39; %}\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\r\n<h3 class=\"fz-ml\">\u624b\u98065: \u4fdd\u5b58\u3057\u3066\u52d5\u4f5c\u78ba\u8a8d<\/h3>\r\n<ol style=\"list-style-type:decimal;\">\r\n<li>\u53f3\u4e0a\u306e\u300c<b class=\"bold\">\u4fdd\u5b58<\/b>\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af<\/li>\r\n<li>\u5bfe\u8c61\u306e\u5546\u54c1\u30da\u30fc\u30b8\u306b\u30a2\u30af\u30bb\u30b9<\/li>\r\n<li>\u300c\u30ab\u30fc\u30c8\u306b\u8ffd\u52a0\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af<\/li>\r\n<li>\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u304c\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u3092\u78ba\u8a8d<\/li>\r\n<\/ol>\r\n<hr class=\"rule-hory mt-3r\">\r\n<h2 class=\"fz-xl\">\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u30dd\u30a4\u30f3\u30c8<\/h2>\r\n<h3 class=\"fz-ml\">\u5bfe\u8c61\u30da\u30fc\u30b8\u306e\u5909\u66f4<\/h3>\r\n<p>URL\u306b\u542b\u307e\u308c\u308b\u6587\u5b57\u5217\u3067\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\r\n<pre><code class=\"language-javascript\">\/\/ \u2605 \u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u3092\u8868\u793a\u3059\u308b\u5546\u54c1\u30da\u30fc\u30b8\u306eURL\u306b\u542b\u307e\u308c\u308b\u6587\u5b57\u5217\r\nconst TARGET_URL_PATTERNS = [&#39;cartridge&#39;];\r\n<\/code><\/pre>\r\n<p>\u8907\u6570\u30d1\u30bf\u30fc\u30f3\u3092\u6307\u5b9a\u3059\u308b\u5834\u5408\uff1a<\/p>\r\n<pre><code class=\"language-javascript\">const TARGET_URL_PATTERNS = [&#39;cartridge&#39;, &#39;refill&#39;, &#39;ink&#39;];\r\n<\/code><\/pre>\r\n<h3 class=\"fz-ml\">\u9077\u79fb\u5148URL\u306e\u5909\u66f4<\/h3>\r\n<p>\u300c\u672c\u4f53\u30da\u30fc\u30b8\u3092\u898b\u308b\u300d\u30dc\u30bf\u30f3\u306e\u9077\u79fb\u5148\u3092\u5909\u66f4\uff1a<\/p>\r\n<pre><code class=\"language-javascript\">\/\/ \u2605 \u300c\u3044\u3044\u3048\u300d\u30dc\u30bf\u30f3\u3067\u9077\u79fb\u3059\u308b\u5148\u306eURL\r\nconst REDIRECT_URL = &#39;\/products\/starterset&#39;;\r\n<\/code><\/pre>\r\n<h3 class=\"fz-ml\">\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u30c6\u30ad\u30b9\u30c8\u5909\u66f4<\/h3>\r\n<p>HTML\u90e8\u5206\u3092\u7de8\u96c6\uff1a<\/p>\r\n<pre><code class=\"language-html\">&lt;div class=&quot;caution-popup-title&quot;&gt;\u3053\u3053\u306b\u30bf\u30a4\u30c8\u30eb&lt;\/div&gt;\r\n&lt;div class=&quot;caution-popup-content&quot;&gt;\u3053\u3053\u306b\u8aac\u660e\u6587&lt;\/div&gt;\r\n<\/code><\/pre>\r\n<p>\u30dc\u30bf\u30f3\u306e\u30e9\u30d9\u30eb\uff1a<\/p>\r\n<pre><code class=\"language-html\">&lt;button ... id=&quot;caution-popup-yes&quot;&gt;\u306f\u3044&lt;\/button&gt;\r\n&lt;button ... id=&quot;caution-popup-no&quot;&gt;\u672c\u4f53\u30da\u30fc\u30b8\u3092\u898b\u308b&lt;\/button&gt;\r\n<\/code><\/pre>\r\n<h3 class=\"fz-ml\">\u30c7\u30b6\u30a4\u30f3\u306e\u5909\u66f4<\/h3>\r\n<p>CSS\u306e\u4e3b\u8981\u306a\u30ab\u30e9\u30fc\u8a2d\u5b9a\uff1a<\/p>\r\n<pre><code class=\"language-css\">\/* \u300c\u306f\u3044\u300d\u30dc\u30bf\u30f3 *\/\r\n.caution-popup-yes { color: #fff; background: #333; }\r\n\r\n\/* \u300c\u3044\u3044\u3048\u300d\u30dc\u30bf\u30f3 *\/\r\n.caution-popup-no { color: #333; background: #ddd; }\r\n\r\n\/* \u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u80cc\u666f *\/\r\n.caution-popup-overlay { background: rgba(0,0,0,0.5); }\r\n<\/code><\/pre>\r\n<h3 class=\"fz-ml\">\u300c\u4eca\u5f8c\u8868\u793a\u3057\u306a\u3044\u300d\u6a5f\u80fd\u3092\u7121\u52b9\u306b\u3059\u308b<\/h3>\r\n<p>\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u304c\u4e0d\u8981\u306a\u5834\u5408\u306f\u3001HTML\u90e8\u5206\u3092\u524a\u9664\uff1a<\/p>\r\n<pre><code class=\"language-html\">&lt;!-- \u3053\u306e\u90e8\u5206\u3092\u524a\u9664 --&gt;\r\n&lt;div class=&quot;caution-popup-remember&quot;&gt;\r\n  ...\r\n&lt;\/div&gt;\r\n<\/code><\/pre>\r\n<hr class=\"rule-hory mt-3r\">\r\n<h2 class=\"fz-xl\">\u6280\u8853\u7684\u306a\u89e3\u8aac<\/h2>\r\n<h3 class=\"fz-ml\">\u306a\u305c\u30a4\u30d9\u30f3\u30c8\u306e\u30ad\u30e3\u30d7\u30c1\u30e3\u30d5\u30a7\u30fc\u30ba\u3092\u4f7f\u3046\u306e\u304b<\/h3>\r\n<p>Shopify\u306e\u591a\u304f\u306e\u30c6\u30fc\u30de\uff08Horizon\u3001Dawn\u306a\u3069\uff09\u306f\u3001\u30ab\u30fc\u30c8\u8ffd\u52a0\u51e6\u7406\u3092JavaScript\u3067\u975e\u540c\u671f\u306b\u884c\u3044\u307e\u3059\u3002\u901a\u5e38\u306e\u30a4\u30d9\u30f3\u30c8\u30ea\u30b9\u30ca\u30fc\u3067\u306f\u3001\u30c6\u30fc\u30de\u306eJavaScript\u3088\u308a\u5148\u306b\u30a4\u30d9\u30f3\u30c8\u3092\u30ad\u30e3\u30c3\u30c1\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\r\n<pre><code class=\"language-javascript\">\/\/ \u7b2c3\u5f15\u6570\u3092 true \u306b\u3059\u308b\u3068\u30ad\u30e3\u30d7\u30c1\u30e3\u30d5\u30a7\u30fc\u30ba\u3067\u5b9f\u884c\r\ndocument.addEventListener(&#39;click&#39;, function(e) {\r\n  \/\/ ...\r\n}, true);\r\n<\/code><\/pre>\r\n<h3 class=\"fz-ml\">override\u30d5\u30e9\u30b0\u306e\u4ed5\u7d44\u307f<\/h3>\r\n<p>\u300c\u306f\u3044\u300d\u30dc\u30bf\u30f3\u30af\u30ea\u30c3\u30af\u6642\u3001\u518d\u5ea6\u30ab\u30fc\u30c8\u8ffd\u52a0\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u304c\u3001\u305d\u306e\u969b\u306b\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u304c\u518d\u8868\u793a\u3055\u308c\u306a\u3044\u3088\u3046\u3001<code>data-override<\/code> \u5c5e\u6027\u3067\u30d5\u30e9\u30b0\u7ba1\u7406\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\r\n<pre><code class=\"language-javascript\">\/\/ \u300c\u306f\u3044\u300d\u30af\u30ea\u30c3\u30af\u6642\r\ncurrentAtcButton.dataset.override = &#39;true&#39;;\r\ncurrentAtcButton.click();  \/\/ \u518d\u30af\u30ea\u30c3\u30af\r\ncurrentAtcButton.dataset.override = &#39;&#39;;\r\n\r\n\/\/ \u30a4\u30d9\u30f3\u30c8\u30ea\u30b9\u30ca\u30fc\u5185\r\nif (btn.dataset.override === &#39;true&#39;) {\r\n  return;  \/\/ \u30d5\u30e9\u30b0\u304c\u3042\u308c\u3070\u30b9\u30ad\u30c3\u30d7\r\n}\r\n<\/code><\/pre>\r\n<h3 class=\"fz-ml\">localStorage\u3067\u306e\u8a18\u61b6<\/h3>\r\n<p>\u300c\u4eca\u5f8c\u3053\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3057\u306a\u3044\u300d\u306b\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u308b\u3068\u3001localStorage\u306b\u4fdd\u5b58\u3055\u308c\u307e\u3059\u3002<\/p>\r\n<pre><code class=\"language-javascript\">localStorage.setItem(&#39;caution_popup_skip&#39;, &#39;true&#39;);\r\n<\/code><\/pre>\r\n<p>\u30d6\u30e9\u30a6\u30b6\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u30af\u30ea\u30a2\u3059\u308b\u304b\u3001\u958b\u767a\u8005\u30c4\u30fc\u30eb\u3067\u524a\u9664\u3059\u308b\u307e\u3067\u6709\u52b9\u3067\u3059\u3002<\/p>\r\n<hr class=\"rule-hory mt-3r\">\r\n<h2 class=\"fz-xl\">\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/h2>\r\n<h3 class=\"fz-ml\">\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u304c\u8868\u793a\u3055\u308c\u306a\u3044<\/h3>\r\n<ol style=\"list-style-type:decimal;\">\r\n<li><code>theme.liquid<\/code> \u306b <code>{% render &#39;popup-caution&#39; %}<\/code> \u304c\u8ffd\u52a0\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d<\/li>\r\n<li>\u5bfe\u8c61URL\u306e\u30d1\u30bf\u30fc\u30f3\uff08<code>TARGET_URL_PATTERNS<\/code>\uff09\u304c\u6b63\u3057\u3044\u304b\u78ba\u8a8d<\/li>\r\n<li>\u30d6\u30e9\u30a6\u30b6\u306e\u958b\u767a\u8005\u30c4\u30fc\u30eb\u3067JavaScript\u30a8\u30e9\u30fc\u304c\u306a\u3044\u304b\u78ba\u8a8d<\/li>\r\n<\/ol>\r\n<h3 class=\"fz-ml\">\u300c\u306f\u3044\u300d\u3092\u62bc\u3057\u3066\u3082\u30ab\u30fc\u30c8\u306b\u8ffd\u52a0\u3055\u308c\u306a\u3044<\/h3>\r\n<p>\u30c6\u30fc\u30de\u306b\u3088\u3063\u3066\u30ab\u30fc\u30c8\u8ffd\u52a0\u30dc\u30bf\u30f3\u306e\u30bb\u30ec\u30af\u30bf\u304c\u7570\u306a\u308a\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u90e8\u5206\u3092\u8abf\u6574\uff1a<\/p>\r\n<pre><code class=\"language-javascript\">const btn = e.target.closest(&#39;button[type=&quot;submit&quot;], .product-form__submit, [name=&quot;add&quot;]&#39;);\r\n<\/code><\/pre>\r\n<h3 class=\"fz-ml\">\u300c\u4eca\u5f8c\u8868\u793a\u3057\u306a\u3044\u300d\u304c\u52b9\u304b\u306a\u3044<\/h3>\r\n<p>localStorage\u304c\u7121\u52b9\u306b\u306a\u3063\u3066\u3044\u306a\u3044\u304b\u78ba\u8a8d\u3002\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30d6\u30e9\u30a6\u30ba\u30e2\u30fc\u30c9\u3067\u306f\u52d5\u4f5c\u3057\u306a\u3044\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\r\n<hr class=\"rule-hory mt-3r\">\r\n<h2 class=\"fz-xl\">\u307e\u3068\u3081<\/h2>\r\n<p>Shopify\u3067\u5546\u54c1\u30ab\u30fc\u30c8\u8ffd\u52a0\u6642\u306b\u78ba\u8a8d\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u3092\u8868\u793a\u3059\u308b\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002<\/p>\r\n<ul class=\"my-0.5r\" style=\"list-style-type:bullet;\">\r\n<li><b class=\"bold\">snippet\u30d5\u30a1\u30a4\u30eb<\/b>\u306b\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306eHTML\/CSS\/JS\u3092\u307e\u3068\u3081\u308b<\/li>\r\n<li><b class=\"bold\">theme.liquid<\/b>\u3067\u8aad\u307f\u8fbc\u3080<\/li>\r\n<li><b class=\"bold\">\u30a4\u30d9\u30f3\u30c8\u306e\u30ad\u30e3\u30d7\u30c1\u30e3\u30d5\u30a7\u30fc\u30ba<\/b>\u3067\u30ab\u30fc\u30c8\u8ffd\u52a0\u3092\u30a4\u30f3\u30bf\u30fc\u30bb\u30d7\u30c8<\/li>\r\n<li><b class=\"bold\">localStorage<\/b>\u3067\u300c\u4eca\u5f8c\u8868\u793a\u3057\u306a\u3044\u300d\u3092\u8a18\u61b6<\/li>\r\n<\/ul>\r\n<p>\u30a2\u30d7\u30ea\u3092\u4f7f\u308f\u305a\u306b\u5b9f\u88c5\u3067\u304d\u308b\u306e\u3067\u3001\u8208\u5473\u306e\u3042\u308b\u65b9\u306f\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\r\n<hr class=\"rule-hory mt-3r\">\r\n<h2 class=\"fz-xl\">\u53c2\u8003\u30ea\u30f3\u30af<\/h2>\r\n<ul class=\"my-0.5r\" style=\"list-style-type:bullet;\">\r\n<li><a href=\"https:\/\/shopify.dev\/docs\/themes\" class=\"link\">Shopify \u30c6\u30fc\u30de\u958b\u767a\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a><\/li>\r\n<li><a href=\"https:\/\/shopify.dev\/docs\/api\/liquid\" class=\"link\">Liquid \u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/a><\/li>\r\n<\/ul>","protected":false},"excerpt":{"rendered":"EC\u30b5\u30a4\u30c8\u3092\u904b\u55b6\u3057\u3066\u3044\u308b\u3068\u3001\u300c\u3053\u306e\u5546\u54c1\u306f\u5358\u4f53\u3067\u306f\u4f7f\u3048\u307e\u305b\u3093\u300d\u300c\u5225\u306e\u5546\u54c1\u3068\u4e00\u7dd2\u306b\u8cfc\u5165\u3057\u3066\u304f\u3060\u3055\u3044\u300d\u3068\u3044\u3063\u305f\u6ce8\u610f\u4e8b\u9805\u3092\u304a\u5ba2\u69d8\u306b\u4f1d\u3048\u305f\u3044\u5834\u9762\u304c\u3042\u308a\u307e\u3059\u3002 \u4f8b\u3048\u3070\uff1a \u30d7\u30ea\u30f3\u30bf\u30fc\u306e\u30a4\u30f3\u30af\u30ab\u30fc\u30c8\u30ea\u30c3\u30b8\uff08\u5bfe\u5fdc\u6a5f\u7a2e\u306e\u78ba\u8a8d\uff09 \u6d44\u6c34\u5668\u306e\u4ea4\u63db[...]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","footnotes":"","vk-ltc-link":"","vk-ltc-target":"0"},"categories":[10],"tags":[567,568,564,565,569,566,563,113,112],"class_list":["post-10562","post","type-post","status-publish","format-standard","category-develop-env","tag-567","tag-568","tag-liquid","tag-565","tag-localstorage","tag-ec","tag-shopify","tag-javascript","tag-112"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/10562","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/comments?post=10562"}],"version-history":[{"count":1,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/10562\/revisions"}],"predecessor-version":[{"id":12666,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/10562\/revisions\/12666"}],"wp:attachment":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/media?parent=10562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/categories?post=10562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/tags?post=10562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}