mdf-3-42

<!--
=====================================================================
  PAGE BRIDGE — Bundle 3 MOIS (Routine 3 mois ⭐ Meilleure offre)
  À coller dans : Shopify Admin → Boutique en ligne → Pages → Page intitulée "mdf-3-42"
  Code discount associé : MDF-3-42 (-42%)
=====================================================================
-->

<style>
  .header, header, .footer, footer,
  .announcement, .announcement-bar,
  #shopify-section-header, #shopify-section-footer,
  [id*="header-section"], [id*="footer-section"],
  .site-header, .site-footer { display: none !important; }
  body { padding: 0 !important; margin: 0 !important; }
  .bridge-container {
    position: fixed; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    z-index: 999999;
  }
  .bridge-spinner {
    width: 40px; height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #10b981;
    border-radius: 50%;
    animation: bridge-spin 0.8s linear infinite;
    margin-bottom: 24px;
  }
  @keyframes bridge-spin { to { transform: rotate(360deg); } }
  .bridge-text { font-size: 16px; color: #374151; margin: 0; text-align: center; }
  .bridge-subtext { font-size: 13px; color: #9ca3af; margin-top: 8px; text-align: center; }
</style>

<div class="bridge-container">
  <div class="bridge-spinner"></div>
  <p class="bridge-text">Application de ta réduction…</p>
  <p class="bridge-subtext">Redirection vers le paiement sécurisé</p>
</div>

<script>
(function () {
  // ==================== CONFIG BUNDLE 3 MOIS ====================
  var VARIANT_ID = "42450356699171";
  var QUANTITY   = 3;
  var DISCOUNT   = "MDF-3-42";
  // ==============================================================

  if (window.Shopify && window.Shopify.designMode) {
    console.log("Editor Shopify — bridge inactive");
    return;
  }

  var SHOP_DOMAIN = "https://" + window.location.hostname;
  var REDIRECT_DEADLINE_MS = 800;
  var redirected = false;

  try {
    var url = new URL(window.location.href);
    var keys = ["fbclid","ttclid","gclid","utm_source","utm_medium","utm_campaign","utm_content","utm_term"];
    keys.forEach(function(k){
      var v = url.searchParams.get(k);
      if (v) localStorage.setItem("_lp_" + k, v);
    });
  } catch (e) {}

  function buildCartUrl() {
    var base = SHOP_DOMAIN + "/cart/" + VARIANT_ID + ":" + QUANTITY;
    var target = new URL(base);
    var merged = new URLSearchParams(target.search);
    var current = new URLSearchParams(window.location.search);
    current.forEach(function(value, key){ merged.set(key, value); });
    if (DISCOUNT) merged.set("discount", DISCOUNT);
    target.search = merged.toString();
    return target.toString();
  }

  function safeRedirect() {
    if (redirected) return;
    redirected = true;
    try {
      if (window.fbq) {
        window.fbq("track", "AddToCart", {
          content_ids: [VARIANT_ID],
          content_type: "product",
          num_items: QUANTITY,
          currency: "EUR"
        });
      }
    } catch (e) {}
    window.location.href = buildCartUrl();
  }

  function setConsentThenRedirect() {
    var fallback = setTimeout(safeRedirect, REDIRECT_DEADLINE_MS);
    function done() {
      clearTimeout(fallback);
      try {
        if (window.Pandectes && window.Pandectes.fn) {
          if (typeof Pandectes.fn.setPreferencesCheckboxes === "function") Pandectes.fn.setPreferencesCheckboxes(8);
          if (typeof Pandectes.fn.savePreferences === "function") Pandectes.fn.savePreferences();
        }
      } catch (e) {}
      safeRedirect();
    }
    try {
      if (!window.Shopify || !window.Shopify.loadFeatures) return done();
      window.Shopify.loadFeatures([{ name: "consent-tracking-api", version: "0.1" }], function () {
        try {
          var cp = window.Shopify && window.Shopify.customerPrivacy;
          if (!cp || !cp.setTrackingConsent) return done();
          var result = cp.setTrackingConsent(
            { analytics: true, marketing: true, preferences: true },
            function () { done(); }
          );
          if (result && typeof result.then === "function") {
            result.then(done).catch(done);
          }
        } catch (e) { done(); }
      });
    } catch (e) { done(); }
  }

  setConsentThenRedirect();
})();
</script>