Fix add-to-cart: bust main.js SW cache, add inline onclick to shop buttons

Service worker was caching main.js (cache-first strategy) so event listeners
may not have been running. Added filemtime version param to main.js like CSS.
Also added inline onclick to shop page buttons so they work regardless of
whether event delegation is functional.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-14 20:11:35 +00:00
parent e389254a7c
commit 6e86031576
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -71,7 +71,7 @@
</div>
</footer>
<script src="/assets/js/main.js"></script>
<script src="/assets/js/main.js?v=<?= filemtime($_SERVER['DOCUMENT_ROOT'] . '/assets/js/main.js') ?>"></script>
<!-- PWA Service Worker Registration -->
<script>
+1 -1
View File
@@ -190,7 +190,7 @@ $productTypesList = db()->fetchAll("SELECT type_id, name, slug FROM product_type
<span class="original"><?= formatCurrency($product['price']) ?></span>
<?php endif; ?>
</div>
<button class="btn btn-primary btn-block add-to-cart-btn" data-product-id="<?= $product['product_id'] ?>">
<button class="btn btn-primary btn-block add-to-cart-btn" data-product-id="<?= $product['product_id'] ?>" onclick="addToCart('<?= $product['product_id'] ?>', 1)">
<i class="fas fa-shopping-bag"></i> Add to Cart
</button>
</div>