<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
   */
  function checkProductVariation(productId, color) {
    console.log('checkProductVariation called');
    console.log('Product ID:', productId);
    console.log('Color:', color);

    // Make AJAX call to find variation with this color
    jQuery.ajax({
      url: 'https://megaradar.com.tr/shop/wp-admin/admin-ajax.php',
      type: 'POST',
      data: {
        action: 'check_product_variation',
        product_id: productId,
        color: color,
        nonce: 'cd6f572fd3'
      },
      success: function(response) {
        if (response.success && response.data.variation_id) {
          // Store in global variables
          selectedProductId = productId;
          selectedVariationId = response.data.variation_id;
          selectedVariationLabel = response.data.variation_label;

          console.log('Variation found:', response.data);

          // Add class to color span
          jQuery('.color-table .stock-colors span.' + response.data.color_class).addClass('quick-color-selected');
        } else {
          console.log('No variation found for color:', color);
        }
      },
      error: function(xhr, status, error) {
        console.error('AJAX error:', error);
      }
    });
  }

  /**
   * 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);

    // Check if variation is selected
    if (!selectedVariationId) {
      alert('Lütfen ürünü sepetinize eklemeden önce bir renk seçin.');
      return;
    }

    console.log('Adding product to cart');
    console.log('Product ID:', selectedProductId);
    console.log('Variation ID:', selectedVariationId);
    console.log('Variation Label:', selectedVariationLabel);
  }
</script>
{"id":23517,"date":"2023-07-11T21:46:13","date_gmt":"2023-07-11T18:46:13","guid":{"rendered":"https:\/\/megaradar.com.tr\/shop\/urun\/762mm-dik-disi-soket-klemens-11-pim\/"},"modified":"2026-03-02T15:21:43","modified_gmt":"2026-03-02T12:21:43","slug":"762mm-vertical-female-pluggable-terminal-block-11-pins","status":"publish","type":"product","link":"https:\/\/megaradar.com.tr\/shop\/en\/product\/762mm-vertical-female-pluggable-terminal-block-11-pins\/","title":{"rendered":"7.62mm Vertical Female Pluggable Terminal Block \u2013 11 Pins"},"content":{"rendered":"","protected":false},"excerpt":{"rendered":"<p class=\"s-desc-mg\"><span>PCB terminal block with screw connection socket with elevator mechanism<\/span><span>11 poles<\/span><span>Max. conductor cross section: <b>2.5mm\u00b2-14 AWG<\/b><\/span><span>Pin pitch: <b>7.62mm<\/b><\/span><span>Rated voltage: <b>400V<\/b><\/span><span>Rated current: <b>16A<\/b><\/span><\/p>\n<ul class=\"s-desc-mg-list\">\n<li>Pluggable connectors offer three installation options: cable-to-cable connection, rail mounting, and surface mounting to suit diverse application needs.<\/li>\n<li>They can be easily fixed onto rails using mounting brackets<\/li>\n<li>It can be easily fixed to the surface with screws via the holes on the terminal block.<\/li>\n<\/ul>\n<div class=\"color-table\">\n<div class=\"s-desc-mg-colors\">\n  <span>Color options<\/span><\/p>\n<div class=\"stock-colors\">\n    <span class=\"blue\"><i>Blue<\/i><\/span><br \/>\n    <span class=\"green\"><i>Green<\/i><\/span><br \/>\n    <span class=\"orange\"><i>Orange<\/i><\/span><br \/>\n    <span class=\"black\"><i>Black<\/i><\/span><br \/>\n    <span class=\"gray\"><i>Gray<\/i><\/span><br \/>\n    <span class=\"red\"><i>Red<\/i><\/span>\n  <\/div>\n<\/div>\n<div class=\"s-desc-mg-stock\">\n  <span class=\"s-desc-mg-stock-title\">Stock color<\/span><\/p>\n<div class=\"stock-colors\">\n    <span class=\"blue\"><i>Blue<\/i><\/span><br \/>\n    <span class=\"green\"><i>Green<\/i><\/span><br \/>\n    <span class=\"orange\"><i>Orange<\/i><\/span>\n  <\/div>\n<\/div>\n<\/div>\n","protected":false},"featured_media":25911,"template":"","meta":[],"product_brand":[],"product_cat":[4212,3977,4315],"product_tag":[],"class_list":{"0":"post-23517","1":"product","2":"type-product","3":"status-publish","4":"has-post-thumbnail","6":"product_cat-pluggable-connectors","7":"product_cat-pluggable-terminal-blocks-and-connectors","8":"product_cat-7-62mm-pluggable-connectors","9":"pa_aksesuarlar-plug-in-bridge","10":"pa_anma-akimi-16a","11":"pa_anma-gerilimi-400v","12":"pa_baglanti-tipi-screw-connection-with-elevator-mechanism","13":"pa_iletken-baglanti-kesiti-0-25mm-23-awg","14":"pa_iletken-baglanti-kesiti-1mm-18-awg","15":"pa_iletken-baglanti-kesiti-1-5mm-16-awg","16":"pa_iletken-baglanti-kesiti-2-5mm-14-awg","17":"pa_iletken-baglanti-yonu-3979","18":"pa_kutup-sayisi-4350","19":"pa_montaj-tipi-cable-to-cable","20":"pa_onaylar-tse","21":"pa_onaylar-ce","22":"pa_onaylar-rohs","23":"pa_onaylar-vde","24":"pa_onaylar-ul","25":"pa_onaylar-eac","26":"pa_pim-araligi-762mm","27":"pa_renk-secenekleri-blue","28":"pa_renk-secenekleri-green","29":"pa_renk-secenekleri-orange","30":"pa_renk-secenekleri-gray","31":"pa_renk-secenekleri-black","32":"pa_renk-secenekleri-red","33":"pa_renk-siparis-kodu-10-761-blue","34":"pa_renk-siparis-kodu-11-761-green","35":"pa_renk-siparis-kodu-12-761-orange","36":"pa_renk-siparis-kodu-13-761-black","37":"pa_renk-siparis-kodu-14-761-gray","38":"pa_renk-siparis-kodu-15-761-red","39":"pa_sira-sayisi-3992","40":"pa_stok-rengi-blue","41":"pa_stok-rengi-green","42":"pa_stok-rengi-orange","43":"pa_urun-grubu-pluggable-connectors","44":"pa_urun-tipi-vertical-female","46":"first","47":"instock","48":"taxable","49":"shipping-taxable","50":"purchasable","51":"product-type-variable"},"_links":{"self":[{"href":"https:\/\/megaradar.com.tr\/shop\/en\/wp-json\/wp\/v2\/product\/23517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/megaradar.com.tr\/shop\/en\/wp-json\/wp\/v2\/product"}],"about":[{"href":"https:\/\/megaradar.com.tr\/shop\/en\/wp-json\/wp\/v2\/types\/product"}],"version-history":[{"count":0,"href":"https:\/\/megaradar.com.tr\/shop\/en\/wp-json\/wp\/v2\/product\/23517\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/megaradar.com.tr\/shop\/en\/wp-json\/wp\/v2\/media\/25911"}],"wp:attachment":[{"href":"https:\/\/megaradar.com.tr\/shop\/en\/wp-json\/wp\/v2\/media?parent=23517"}],"wp:term":[{"taxonomy":"product_brand","embeddable":true,"href":"https:\/\/megaradar.com.tr\/shop\/en\/wp-json\/wp\/v2\/product_brand?post=23517"},{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/megaradar.com.tr\/shop\/en\/wp-json\/wp\/v2\/product_cat?post=23517"},{"taxonomy":"product_tag","embeddable":true,"href":"https:\/\/megaradar.com.tr\/shop\/en\/wp-json\/wp\/v2\/product_tag?post=23517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}