private function get_javascript() { return ' jQuery(document).ready(function($) { $(".rnd-nav-tab").on("click", function(e) { e.preventDefault(); var tabId = $(this).data("tab"); $(".rnd-nav-tab").removeClass("nav-tab-active"); $(this).addClass("nav-tab-active"); $(".rnd-tab-pane").hide(); $("#tab-" + tabId).show(); }); var searchTimer; var currentSku = ""; function updatePriceDisplay() { var d = window.currentProductData; if (!d) return; var distribution = d.Distribution || {}; var useMapPrice = $("#use-map-price").is(":checked"); var profitMargin = parseFloat($("#rnd-profit-margin").val()) || 30; var map = parseFloat(d.MAP || distribution.MAP || 0); var msrp = parseFloat(d.MSRP || distribution.MSRP || 0); var distributorCost = parseFloat(distribution.Price || 0); var finalPrice = 0; var priceMethod = ""; if (useMapPrice && map > 0) { finalPrice = map; priceMethod = "MAP price (no margin)"; } else { if (map > 0) { finalPrice = map * (1 + profitMargin / 100); priceMethod = "MAP + " + profitMargin + "% margin"; } else if (msrp > 0) { finalPrice = msrp * (1 + profitMargin / 100); priceMethod = "MSRP + " + profitMargin + "% margin"; } else if (distributorCost > 0) { finalPrice = distributorCost * (1 + profitMargin / 100); priceMethod = "Distributor Price + " + profitMargin + "% margin"; } } $(".rnd-final-price .rnd-price-label").html("💰 Your Selling Price (" + priceMethod + "):"); $(".rnd-final-price .rnd-price-value").text("$" + finalPrice.toFixed(2)); $("#rnd-import-btn").data("use-map-price", useMapPrice); $("#rnd-import-btn").data("profit-margin", profitMargin); } function doSearch() { var sku = $("#rnd-sku-input").val().trim(); if (!sku) return; currentSku = sku; $("#rnd-preview-body").html("

Searching...

"); $("#rnd-preview-wrap").show(); $("#rnd-import-btn").hide(); $("#rnd-import-result").text(""); $("#use-map-price-container").hide(); $.post(randmar_ajax.url, { action: "randmar_search_sku", sku: sku, nonce: randmar_ajax.nonce }, function(response) { if (!response.success) { $("#rnd-preview-body").html("

✗ " + (response.data || "Product not found") + "

"); return; } window.currentProductData = response.data; var d = response.data; var distribution = d.Distribution || {}; var profitMargin = parseFloat($("#rnd-profit-margin").val()) || 30; var map = parseFloat(d.MAP || distribution.MAP || 0); var msrp = parseFloat(d.MSRP || distribution.MSRP || 0); var distributorCost = parseFloat(distribution.Price || 0); // Show/hide MAP checkbox if (map > 0) { $("#use-map-price-container").show(); } else { $("#use-map-price-container").hide(); $("#use-map-price").prop("checked", false); } var finalPrice = 0; var useMapPrice = $("#use-map-price").is(":checked"); if (useMapPrice && map > 0) { finalPrice = map; } else { if (map > 0) { finalPrice = map * (1 + profitMargin / 100); } else if (msrp > 0) { finalPrice = msrp * (1 + profitMargin / 100); } else if (distributorCost > 0) { finalPrice = distributorCost * (1 + profitMargin / 100); } } var stock = 0; if (distribution.Inventory) { $.each(distribution.Inventory, function(i, inv) { stock += parseInt(inv.AvailableQuantity || inv.Quantity || 0); }); } var description = d.BodyHTML || ""; var shortDesc = description.length > 200 ? description.substring(0, 200) + "..." : description; // Direct thumbnail URL with 100px width var thumbnailUrl = "https://api.randmar.io/Product/" + encodeURIComponent(sku) + "/Image?width=100"; var thumbnailHtml = "
" + "\"Product" + "
"; var html = thumbnailHtml + "
" + "

SKU: " + escapeHtml(d.RandmarSKU) + "

" + "

Name: " + escapeHtml(d.Title || d.RandmarTitle || d.RandmarSKU) + "

" + "

Brand: " + escapeHtml(d.ManufacturerName || "N/A") + "

" + "

Category: " + escapeHtml(d.Category || "N/A") + "

" + "
" + "
🏷️ MAP: $" + map.toFixed(2) + "
" + "
⭐ MSRP: $" + msrp.toFixed(2) + "
" + "
📦 Distributor Price: $" + distributorCost.toFixed(2) + "
" + "
💰 Your Selling Price: $" + finalPrice.toFixed(2) + "
" + "
" + "

📊 Stock: " + stock + " units

" + "

✅ Available: " + (d.AvailableToBuy ? "Yes" : "No") + "

" + "

📸 Images: " + (d.Images ? d.Images.length : 0) + " available

" + (shortDesc ? "

📝 Description: " + escapeHtml(shortDesc) + "

" : "") + "
"; $("#rnd-preview-body").html(html); updatePriceDisplay(); $("#rnd-import-btn").show().data("sku", d.RandmarSKU); }).fail(function() { $("#rnd-preview-body").html("

✗ Server error during search

"); }); } function escapeHtml(str) { if (!str) return ""; return $("
").text(str).html(); } $("#rnd-sku-input").on("input", function() { clearTimeout(searchTimer); var val = $(this).val().trim(); if (val.length < 2) { $("#rnd-preview-wrap").hide(); return; } searchTimer = setTimeout(doSearch, 800); }).on("keypress", function(e) { if (e.which === 13) { e.preventDefault(); doSearch(); } }); $("#rnd-search-btn").on("click", function() { doSearch(); }); $("#rnd-profit-margin").on("change", function() { if (window.currentProductData) { updatePriceDisplay(); } }); $("#use-map-price").on("change", function() { if (window.currentProductData) { updatePriceDisplay(); } }); $("#rnd-import-btn").on("click", function() { var sku = $(this).data("sku"); var profitMargin = $("#rnd-profit-margin").val(); var useMapPrice = $("#use-map-price").is(":checked"); var btn = $(this); btn.prop("disabled", true).text("Importing..."); $("#rnd-import-result").text("Importing product...").css("color", "#555"); $.post(randmar_ajax.url, { action: "randmar_import_sku", sku: sku, profit_margin: profitMargin, use_map_price: useMapPrice, nonce: randmar_ajax.nonce }, function(response) { if (response.success) { $("#rnd-import-result").css("color", "#46b450").html("✅ Imported! View product #" + response.data.product_id + ""); setTimeout(function() { $("#rnd-sku-input").val("").trigger("input"); $("#rnd-preview-wrap").hide(); $("#use-map-price-container").hide(); window.currentProductData = null; }, 5000); } else { $("#rnd-import-result").css("color", "#c00").text("✗ " + response.data); } btn.prop("disabled", false).text("⬇ Import Product"); }).fail(function() { $("#rnd-import-result").css("color", "#c00").text("✗ Server error during import"); btn.prop("disabled", false).text("⬇ Import Product"); }); }); $("#rnd-clear-log").on("click", function() { if (confirm("Clear the import log?")) { $.post(randmar_ajax.url, { action: "randmar_clear_log", nonce: randmar_ajax.nonce }) .done(function() { location.reload(); }); } }); $("#rnd-test-conn").on("click", function() { var btn = $(this); btn.prop("disabled", true).text("Testing..."); $("#rnd-test-result").text(""); $.post(randmar_ajax.url, { action: "randmar_test_connection", nonce: randmar_ajax.nonce }, function(response) { if (response.success) { $("#rnd-test-result").css("color", "#46b450").text("✅ " + response.data); } else { $("#rnd-test-result").css("color", "#c00").text("❌ " + response.data); } btn.prop("disabled", false).text("Test Connection"); }).fail(function() { $("#rnd-test-result").css("color", "#c00").text("❌ Server error"); btn.prop("disabled", false).text("Test Connection"); }); }); }); '; } https://supplieshut.com/post-sitemap.xml 2025-01-25T08:40:52+00:00 https://supplieshut.com/page-sitemap.xml 2026-03-25T07:20:14+00:00 https://supplieshut.com/elementskit_content-sitemap.xml 2021-02-13T07:41:13+00:00 https://supplieshut.com/product-sitemap.xml 2026-05-06T07:40:06+00:00 https://supplieshut.com/tbay_footer-sitemap.xml 2026-03-12T06:57:57+00:00 https://supplieshut.com/tbay_brand-sitemap.xml 2018-11-28T07:54:33+00:00 https://supplieshut.com/tbay_testimonial-sitemap.xml 2025-01-22T08:12:06+00:00 https://supplieshut.com/tbay_megamenu-sitemap.xml 2021-09-30T01:16:27+00:00 https://supplieshut.com/tbay_customtab-sitemap.xml 2025-01-23T06:36:02+00:00 https://supplieshut.com/category-sitemap.xml 2025-01-25T08:40:52+00:00