Best Products
Launches
Launch archive
Most-loved launches by the community
Launch Guide
Checklists and pro tips for launching
News
Newsletter
The best of Product Hunt, every day
Stories
Tech news, interviews, and tips from makers
Changelog
New Product Hunt features and releases
Forums
Forums
Ask questions, find support, and connect
Kitty Points Leaderboard
The highest scoring community members
Streaks
The most active community members
Events
Meet others online and in-person
Advertise
Subscribe
Sign in
Clear text
recent
p/general
by
leshan wang
•
2mo ago
My 7-Day Journal Rebuilding a Medical Shop with MyMedi HTML Template
... Cart" button, updated an array stored in the user's browser, and dynamically re-rendered the template's HTML cart elements without causing a single page reload. Here is the modular script I wrote to manage this: const
MiniCart
= { storageKey: 'mymedi_cart_items', items: [], init() { this.loadCart(); this.bindEvents(); this.render(); }, loadCart() { const stored = localStorage.getItem(this.storageKey); this.items = stored ? JSON.parse(stored) : []; }, saveCart() { localStorage.setItem(this.storageKey, JSON.stringify(this.items)); this.render(); }, bindEvents() { document.addEventListener('click', (e) => { const btn = e.target.closest('.add-to-cart-btn'); if (btn) { e.preventDefault(); const product ...
0
1
Subscribe
Sign in