<?php if (!defined('STORE_ROOT')) { http_response_code(403); exit; }  $dualProducts = []; try { $dualProducts = DB::all( "SELECT id, name, image_path, base_price, notes FROM products WHERE store_id = :sid AND status = 'active' ORDER BY display_order ASC, id ASC LIMIT 2", [':sid' => $storeId] ); } catch (\Throwable $e) {} foreach ($dualProducts as &$dp) { $dp['title'] = Crypt::d($dp['name'] ?? ''); $dp['short_desc'] = Crypt::d($dp['notes'] ?? ''); $dp['image_url'] = $dp['image_path'] ?? ''; $dp['price'] = (float)Crypt::d($dp['base_price'] ?? '0'); $dp['sale_price'] = 0; $dp['display_price'] = $dp['price']; $dp['units'] = []; try { $dp['units'] = DB::all("SELECT id, unit_amount, unit_price FROM product_units WHERE product_id = :pid ORDER BY display_order ASC", [':pid' => (int)$dp['id']]); foreach ($dp['units'] as &$u) { $u['unit_amount'] = Crypt::d($u['unit_amount']); $u['unit_price'] = (float)Crypt::d($u['unit_price']); } unset($u); } catch (\Throwable $e) {} } unset($dp); $featureTitle = $rowConfig['feature_title'] ?? 'Why ' . ($siteName ?? 'Us') . '?'; $featureBody = $rowConfig['feature_body'] ?? 'We source only the highest-grade products, verified for purity and potency.'; $featureChecklist = $rowConfig['feature_checklist'] ?? ['Lab-verified purity', 'Tracked shipping', 'Encrypted checkout', '30-day guarantee']; if (empty($dualProducts)) return; ?> <section id="row-dual-<?= $rowIdx ?>" class="sf-row sf-dual-showcase" data-row-id="<?= (int)$row['id'] ?>">     <div class="sf-dual-grid">         <div class="sf-dual-products">             <?php foreach ($dualProducts as $dp): $pid = (int)$dp['id']; $unitsJson = htmlspecialchars(json_encode($dp['units']), ENT_QUOTES); ?>             <article id="dual-product-<?= $pid ?>" class="sf-dual-product" data-product-id="<?= $pid ?>" data-base-price="<?= $dp['display_price'] ?>" data-units="<?= $unitsJson ?>">                 <div class="sf-dual-img">                     <?php if (!empty($dp['image_url'])): ?>                     <a href="?v=product&id=<?= $pid ?>" route="product"><img src="<?= htmlspecialchars($dp['image_url']) ?>" alt="<?= htmlspecialchars($dp['title']) ?>"></a>                     <?php else: ?>                     <div class="sf-card-img-empty"></div>                     <?php endif; ?>                 </div>                 <div class="sf-dual-info">                     <h3 class="sf-dual-title"><a href="?v=product&id=<?= $pid ?>" route="product"><?= htmlspecialchars($dp['title']) ?></a></h3>                     <p class="sf-dual-desc"><?= htmlspecialchars($dp['short_desc']) ?></p>                     <?php if (!empty($dp['units'])): ?>                     <div class="sf-unit-selector" data-pid="<?= $pid ?>">                         <?php foreach ($dp['units'] as $ui => $u): ?>                         <button class="sf-unit<?= $ui === 0 ? ' active' : '' ?>" data-unit-price="<?= $u['unit_price'] ?>"><?= htmlspecialchars($u['unit_amount']) ?></button>                         <?php endforeach; ?>                     </div>                     <?php endif; ?>                     <div class="sf-dual-price-row">                         <span id="dual-price-<?= $pid ?>" class="sf-card-price" data-base="<?= $dp['display_price'] ?>">$<?= number_format($dp['display_price'], 2) ?></span>                         <a class="sf-btn-buy sf-btn-sm" href="?v=checkout&id=<?= $pid ?>&qty=1" route="checkout">Buy</a>                     </div>                 </div>             </article>             <?php endforeach; ?>         </div>         <div class="sf-feature-panel">             <h3 class="sf-feature-title"><?= htmlspecialchars($featureTitle) ?></h3>             <p class="sf-feature-body"><?= $featureBody ?></p>             <ul class="sf-checklist">                 <?php foreach ($featureChecklist as $item): ?>                 <li><?= htmlspecialchars($item) ?></li>                 <?php endforeach; ?>             </ul>         </div>     </div> </section>
