The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> HTML 5 - Store Counter that switches item to "sold out" after a certain number of purchases / clicks
bigmowebsites
post Aug 7 2020, 10:52 AM
Post #1





Group: Members
Posts: 8
Joined: 7-August 20
Member No.: 27,478



Hello WDG Community-

I am in the process of creating an HTML 5 website for a friend - the site is coming along nicely, however I am struggling with one specific thing; my friend wants a feature implemented where the system will count how many items are sold, and then once the item is sold, it will no longer let the item be purchased. For example -
My friend has 10 shirts he wants to sell. Once 10 of them have been sold, is there a way to make the button non clickable until the item is back in stock? I think this requires a server to be implemented - if so I can try to download a virtual server on my PC.

Thanks in advance, any help is greatly appreciated smile.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 7 2020, 01:28 PM
Post #2


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



Usually this is done with a database (MySQL is free and popular) where you can list every product in a database table by e.g. product number, price, inventory etc.

If the site is extremely simple (like just those ten t-shirts) you might read and write to a textfile instead (a so called flat-file database) using e.g. PHP.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Aug 8 2020, 10:58 AM
Post #3


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



This isn't about markup, so I'm moving it to the server-side programming forum.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
bigmowebsites
post Aug 10 2020, 09:27 AM
Post #4





Group: Members
Posts: 8
Joined: 7-August 20
Member No.: 27,478



QUOTE(Christian J @ Aug 7 2020, 02:28 PM) *

Usually this is done with a database (MySQL is free and popular) where you can list every product in a database table by e.g. product number, price, inventory etc.

If the site is extremely simple (like just those ten t-shirts) you might read and write to a textfile instead (a so called flat-file database) using e.g. PHP.


Thanks for your response! Yes the site will be pretty simple - is there anyway you could direct me to a tutorial on how to implement this?

Thanks again!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 10 2020, 01:22 PM
Post #5


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



Details would depend on how the sales are done. Are you using some kind of order form and associated server-side script?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
bigmowebsites
post Aug 10 2020, 01:31 PM
Post #6





Group: Members
Posts: 8
Joined: 7-August 20
Member No.: 27,478



We were planning on just using Paypal's easy buttons to handle the transactions. I implemented a "add to cart" button for each item. https://www.paypal.com/buttons/
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 11 2020, 05:14 AM
Post #7


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



QUOTE(bigmowebsites @ Aug 10 2020, 08:31 PM) *

We were planning on just using Paypal's easy buttons to handle the transactions. I implemented a "add to cart" button for each item. https://www.paypal.com/buttons/

I didn't try to create a button code, but I suppose it creates a link to Paypal? In that case it might be tricky to also run a counter script on your own server in a reliable way --in particular, if the user cancels the Paypal payment your counter has still registered it as a purchase.

It's better if the counter only runs after the payment has been made. For example, if Paypal also creates a redirect back to a Thank You page on your own site (does it?) maybe you could let a PHP script on that Thank You-page update the counter file.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 11 2020, 05:37 AM
Post #8


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



Agreed. cool.gif

Christian, can you take a look at this? It's driving me nuts. I must miss something.
https://forums.htmlhelp.com/index.php?showtopic=60372
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
bigmowebsites
post Aug 11 2020, 11:43 AM
Post #9





Group: Members
Posts: 8
Joined: 7-August 20
Member No.: 27,478



QUOTE(Christian J @ Aug 11 2020, 06:14 AM) *

QUOTE(bigmowebsites @ Aug 10 2020, 08:31 PM) *

We were planning on just using Paypal's easy buttons to handle the transactions. I implemented a "add to cart" button for each item. https://www.paypal.com/buttons/

I didn't try to create a button code, but I suppose it creates a link to Paypal? In that case it might be tricky to also run a counter script on your own server in a reliable way --in particular, if the user cancels the Paypal payment your counter has still registered it as a purchase.

It's better if the counter only runs after the payment has been made. For example, if Paypal also creates a redirect back to a Thank You page on your own site (does it?) maybe you could let a PHP script on that Thank You-page update the counter file.


This is a very good point. I am going to run this past my friend and see if he wants to change the setup. Thank you for your help!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 04:28 AM