bep40 commited on
Commit
37ce00c
·
verified ·
1 Parent(s): 4525bb2

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +28 -1
index.html CHANGED
@@ -2440,7 +2440,34 @@ function init(){buildCats();buildPrices();buildBrands();render();
2440
  // Try path-based routing first, then hash-based
2441
  if(!parseCurrentPath()){parseUrlParams();render();}
2442
  }
2443
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2444
  document.addEventListener('DOMContentLoaded',()=>{
2445
  initCatalogue();
2446
  updateCartBadge();
 
2440
  // Try path-based routing first, then hash-based
2441
  if(!parseCurrentPath()){parseUrlParams();render();}
2442
  }
2443
+ // Handle ?quote= parameter — auto-add products to cart + open quotation
2444
+ (function(){
2445
+ let params = new URLSearchParams(location.search);
2446
+ let quoteParam = params.get('quote');
2447
+ if(quoteParam){
2448
+ let skus = quoteParam.split(',').map(s=>s.trim()).filter(Boolean);
2449
+ // Wait for products to load
2450
+ let waitForD = setInterval(function(){
2451
+ if(typeof D !== 'undefined' && D.length > 0 && typeof addToCart === 'function'){
2452
+ clearInterval(waitForD);
2453
+ skus.forEach(function(sku){
2454
+ let skuClean = sku.toLowerCase().replace(/[.\- ]/g,'');
2455
+ let idx = D.findIndex(function(p){
2456
+ return (p.sku||'').toLowerCase().replace(/[.\- ]/g,'') === skuClean ||
2457
+ (p.model||'').toLowerCase().replace(/[.\- ]/g,'') === skuClean;
2458
+ });
2459
+ if(idx >= 0) addToCart(idx);
2460
+ });
2461
+ // Open quotation after adding
2462
+ setTimeout(function(){
2463
+ if(typeof openQuotation === 'function') openQuotation();
2464
+ else if(typeof openCart === 'function') openCart();
2465
+ }, 500);
2466
+ }
2467
+ }, 500);
2468
+ setTimeout(function(){ clearInterval(waitForD); }, 15000);
2469
+ }
2470
+ })();
2471
  document.addEventListener('DOMContentLoaded',()=>{
2472
  initCatalogue();
2473
  updateCartBadge();