  <script>
    // Global variables to store selected variation
    let selectedProductId = null;
    let selectedVariationId = null;
    let selectedVariationLabel = null;

    /**
     * Check product variation by color
     * @param {number} productId - The product ID
     * @param {string} color - The selected color
     * @param {element} element - The clicked color span element
     */
    function checkProductVariation(productId, color, element) {
      console.log('checkProductVariation called');
      console.log('Product ID:', productId);
      console.log('Color:', color);

      // If element already has the selected class, return early
      if (jQuery(element).hasClass('quick-color-selected')) {
        console.log('Color already selected');
        return;
      }

      // Reset global variables
      selectedProductId = null;
      selectedVariationId = null;
      selectedVariationLabel = null;

      // Make sure jQuery is available
      if (typeof jQuery === 'undefined') {
        console.error('jQuery is not loaded');
        return;
      }

      // Find the color section wrapper
      var $colorSection = jQuery(element).closest('.s-desc-mg-colors');

      // Add loading class
      $colorSection.addClass('loading');

      // Make AJAX call to find variation with this color
      jQuery.ajax({
        url: 'https://megaradar.com.tr/shop/wp-admin/admin-ajax.php',
        type: 'POST',
        dataType: 'json',
        data: {
          action: 'check_product_variation',
          product_id: productId,
          color: color,
          nonce: 'cd6f572fd3'
        },
        success: function(response) {
          console.log('AJAX success:', response);
          if (response.success && response.data.variation_id) {
            if (!response.data.in_stock) {
              alert('Seçtiğiniz renk stoklarımızda mevcut değildir. Adetlere bağlı olarak tüm renklerin üretimi yapılabilmektedir. Size destek olabilmemiz için bizimle iletişime geçin.');
              return;
            }
            // Store in global variables
            selectedProductId = productId;
            selectedVariationId = response.data.variation_id;
            selectedVariationLabel = response.data.variation_label;

            console.log('Variation found:', response.data);
            // Remove all "quick-color-selected" classes from all products
            jQuery('.quick-color-selected').removeClass('quick-color-selected');


            // Add class to the clicked element
            jQuery(element).addClass('quick-color-selected');
          } else {
            console.log('No variation found for color:', color);
          }
        },
        error: function(xhr, status, error) {
          console.error('AJAX error:', error);
          console.error('Status:', status);
          console.error('Response:', xhr.responseText);
        },
        complete: function() {
          // Remove loading class after response (success or error)
          $colorSection.removeClass('loading');
        }
      });
    }

    /**
     * Quick add product to cart
     * @param {number} productId - The product ID to add to cart
     */
    function quickAddProduct(productId) {
      console.log('quickAddProduct called');
      console.log('Product ID:', productId);

      console.log('Global');
      console.log('Product ID:', selectedProductId);
      console.log('Variation ID:', selectedVariationId);
      console.log('Variation Label:', selectedVariationLabel);
      if (selectedVariationId && selectedProductId === productId) {
        // Redirect to add-to-cart URL for the selected variation
        var addToCartUrl = 'https://megaradar.com.tr/shop/?add-to-cart=' + selectedProductId + '&variation_id=' + selectedVariationId;
        console.log('Redirecting to:', addToCartUrl);
        // window.location.href = addToCartUrl;
      } else {
        alert('Lütfen bu ürünü sepetinize eklemeden önce sipariş kodu/ürün rengi seçin.');
      }
    }
  </script>
{"version":"1.0","provider_name":"Mega Radar","provider_url":"https:\/\/megaradar.com.tr\/shop","author_name":"admin","author_url":"https:\/\/megaradar.com.tr\/shop\/author\/admin\/","title":"Soket K\u00f6pr\u00fcs\u00fc - 7.62mm Di\u015fi Klemensler i\u00e7in - Mega Radar","type":"rich","width":600,"height":338,"html":"<blockquote class=\"wp-embedded-content\" data-secret=\"1Gsc3QTHo8\"><a href=\"https:\/\/megaradar.com.tr\/shop\/urun\/soket-koprusu-762mm-disi-klemensler-icin\/\">Soket K\u00f6pr\u00fcs\u00fc &#8211; 7.62mm Di\u015fi Klemensler i\u00e7in<\/a><\/blockquote><iframe sandbox=\"allow-scripts\" security=\"restricted\" src=\"https:\/\/megaradar.com.tr\/shop\/urun\/soket-koprusu-762mm-disi-klemensler-icin\/embed\/#?secret=1Gsc3QTHo8\" width=\"600\" height=\"338\" title=\"&#8220;Soket K\u00f6pr\u00fcs\u00fc &#8211; 7.62mm Di\u015fi Klemensler i\u00e7in&#8221; &#8212; Mega Radar\" data-secret=\"1Gsc3QTHo8\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" class=\"wp-embedded-content\"><\/iframe><script type=\"text\/javascript\">\n\/* <![CDATA[ *\/\n\/*! This file is auto-generated *\/\n!function(d,l){\"use strict\";l.querySelector&&d.addEventListener&&\"undefined\"!=typeof URL&&(d.wp=d.wp||{},d.wp.receiveEmbedMessage||(d.wp.receiveEmbedMessage=function(e){var t=e.data;if((t||t.secret||t.message||t.value)&&!\/[^a-zA-Z0-9]\/.test(t.secret)){for(var s,r,n,a=l.querySelectorAll('iframe[data-secret=\"'+t.secret+'\"]'),o=l.querySelectorAll('blockquote[data-secret=\"'+t.secret+'\"]'),c=new RegExp(\"^https?:$\",\"i\"),i=0;i<o.length;i++)o[i].style.display=\"none\";for(i=0;i<a.length;i++)s=a[i],e.source===s.contentWindow&&(s.removeAttribute(\"style\"),\"height\"===t.message?(1e3<(r=parseInt(t.value,10))?r=1e3:~~r<200&&(r=200),s.height=r):\"link\"===t.message&&(r=new URL(s.getAttribute(\"src\")),n=new URL(t.value),c.test(n.protocol))&&n.host===r.host&&l.activeElement===s&&(d.top.location.href=t.value))}},d.addEventListener(\"message\",d.wp.receiveEmbedMessage,!1),l.addEventListener(\"DOMContentLoaded\",function(){for(var e,t,s=l.querySelectorAll(\"iframe.wp-embedded-content\"),r=0;r<s.length;r++)(t=(e=s[r]).getAttribute(\"data-secret\"))||(t=Math.random().toString(36).substring(2,12),e.src+=\"#?secret=\"+t,e.setAttribute(\"data-secret\",t)),e.contentWindow.postMessage({message:\"ready\",secret:t},\"*\")},!1)))}(window,document);\n\/\/# sourceURL=https:\/\/megaradar.com.tr\/shop\/wp-includes\/js\/wp-embed.min.js\n\/* ]]> *\/\n<\/script>\n","thumbnail_url":"https:\/\/megaradar.com.tr\/shop\/wp-content\/uploads\/2026\/02\/soket-koprusu-762mm-disi-klemensler-icin-1200x1200-1.jpg","thumbnail_width":1200,"thumbnail_height":1200,"description":"Nominal gerilim: 250VNominal ak\u0131m: 16AUyumlu klemens: 7.62mm  Klemensler aras\u0131nda ak\u0131m transferi sa\u011flar.  Renk se\u00e7enekleri    Nat\u00fcrel    Stok rengi    Metalik"}