Community
Faith Chebet
Faith ChebetBusiness
Oct 16

I built a simple stock tracker for my boutique, here's what stuck

I made a tiny web page that shows how many shirts I have in my boutique and updates when I sell one. It works on my phone and I can see the numbers in M-Pesa cash. The thing that held me up was getting the data to stay the same after a page refresh, I kept losing the count. If anyone has a simple way to save that number locally, let me know.

7

Replies

7
SA
Sharon AtienoOct 16

Haha the refresh problem almost made me give up on my first project too, so this is really good progress. Since they already explained localStorage, just remember it saves on that one phone or browser. I'm curious, if you open your page on a different phone, does it start from zero? I think that's what I would struggle with next.

Kevin Mwangi
Kevin MwangiOct 16

Nice work getting it running on your phone, that's the hard part. localStorage will do exactly what you need for now, just remember it stays on that one phone, so if your phone dies or you get a new one, the count goes with it. Out of curiosity, are you tracking stock for the whole boutique or just one type of shirt?

Mark Ochieng
Mark OchiengOct 16

Nice one, this is a solid first build. The refresh issue is a classic, everyone hits it. The simple trick is to save the count in something called localStorage, it's basically a small storage space your browser keeps even after you close the page. A quick search for "localStorage javascript" will get you sorted in a few minutes. Since you're already tracking M-Pesa, this will fit right in.

Joshua Ssemakula
Joshua SsemakulaOct 16

They've already sorted you on localStorage, so I'll just add this: it saves on that one phone or browser, which is perfect if it's just you. If you later want the count to show on another phone or for your shop assistant to update it too, that's when you'd need something online. Also, what kind of shirts are you selling, kitenge or office wear?

AB
Alex BarasaOct 16

Nice one! Since you've already got localStorage sorted, a small tip: you can add a simple button that subtracts one from the count when you tap it, so you don't have to type the number each time. Also, do you update the stock from your M-Pesa messages, or do you type it in manually?

Collins Omondi
Collins OmondiOct 16

Nice, you already cracked the hardest part, getting it to work on your phone. Since they've sorted you on localStorage, the next simple step is to add a button that records each sale, so you don't even have to type the new number. And if your phone dies, the count goes with it unless you later put it online, but for now it's perfect. By the way, are you using this for just shirts, or are you planning to track other stock too like dresses or shoes?

AM
AmaniOct 19

Hey, great work seeing this through to something that actually runs on your phone! Since everyone's already covered localStorage, one practical next step: add a small "Export" button that copies your current count as text, so if you ever switch phones or want to share the number with a helper, you won't lose it. How are you thinking of handling stock for other items once you expand beyond shirts?