473,788 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

advice on placing items into cart and quantities

You have ordered one item and placed it into your cart. Let's say you
ordered one small black t-shirt. Your cart will have the product_id,
color_id and size_id for the small black t-shirt. The quantity of this item
is, let's say 30. You have one in your cart, so how many are available:

1) 29
2) 30

Now let's say that while I ordered one small black t-shirt, Sven ordered 1
small black t-shirt, Anders ordered one black t-shirt, and Olov ordered one
black t-shirt. If all four of us, at one time, are all ordering the same
item and putting it into our carts, how many should there be available to
us:

1) 26
2) 25
3) 29
4) 30

This is where the contention comes in. The client wants it done "FIFO"
(First In First Out) meaning that whoever gets it first will subtract the
quantity - but I dispute that (coming from somewhat of a Java background)
that since PHP doesn't so single-threading, that means that all four of us
could order t-shirts, but the quantity has to reflect that all four of us
are ordering (multi-threading).

I dunno, help!

Phil
Jul 17 '05 #1
7 1948
RG

"Phil Powell" <so*****@erols. com> wrote in message
news:eF8eb.2567 2$sp2.7183@lake read04...
You have ordered one item and placed it into your cart. Let's say you
ordered one small black t-shirt. Your cart will have the product_id,
color_id and size_id for the small black t-shirt. The quantity of this item is, let's say 30. You have one in your cart, so how many are available:

1) 29
2) 30

Now let's say that while I ordered one small black t-shirt, Sven ordered 1
small black t-shirt, Anders ordered one black t-shirt, and Olov ordered one black t-shirt. If all four of us, at one time, are all ordering the same
item and putting it into our carts, how many should there be available to
us:

1) 26
2) 25
3) 29
4) 30

This is where the contention comes in. The client wants it done "FIFO"
(First In First Out) meaning that whoever gets it first will subtract the
quantity - but I dispute that (coming from somewhat of a Java background)
that since PHP doesn't so single-threading, that means that all four of us
could order t-shirts, but the quantity has to reflect that all four of us
are ordering (multi-threading).

I dunno, help!

Phil

You gonna go round in circles here mate.
What are the chances of multiple people buying the same item in a short
period?
WHat you should do is subtract from the qty when the trtansaction is
complete.

This is why you do not want to follow your current path:
Scenario: I go to your shop and put your entire stock into my basket.
This would stop any legit shopper from being able to put anythin in there
basket.

Just reduce qty when transaction is successful
Hope this helps
RG

Jul 17 '05 #2
On Tue, 30 Sep 2003 01:37:25 -0400, Phil Powell wrote:
This is where the contention comes in. The client wants it done "FIFO"
(First In First Out) meaning that whoever gets it first will subtract the
quantity - but I dispute that (coming from somewhat of a Java background)
that since PHP doesn't so single-threading, that means that all four of us
could order t-shirts, but the quantity has to reflect that all four of us
are ordering (multi-threading).

I dunno, help!


How about the quantity available is the stock quantity (in the product or
stock table) minus the "in basket" quantity (from the basket table). That
way the stock is available and allocated to people. When your baskets
expire (as per your other post) the record that allocates them will be
deleted and hence your stock will then be available for other people.

This means that RG would have to keep doing this every time his basket
expired. If you shorten your expiry time (I would say 24 hours is too
long) it makes it very unfeasible to do what RG suggests (and if someone
writes a script to hit your server every few hours you can block them).

As some advice I would set baskets to expire after 1-2 hours of inactivity
and have every page on your site update the basket time when hit. That
way if the person is still actively looking around your site the basket
expiry will be refreshed and if they leave it won't hang around for long.

You could also give people the option to "Save my basket for later" which
would then put the expiry date 10 years in the future. However, this
opens you back up to RG's attack *.

Most web customers are very quick to jump ship. If they find something
they like they'll buy it. If they actually go to the effort to put it in
their basket they will buy it there and then, unless something makes them
leave the site - when they return virtually no customer would expect their
basket to still be there (would you in a traditional shop?).

And finally, in answer to your earlier post - yes I have "some" (<g>)
experience of writing shopping basket systems.

Cheers,
Andy
* Meaning the attack that RG suggested, not that RG will actually be
attacking your server. :-)
Jul 17 '05 #3
RG

"Andy Jeffries" <ne**@andyjeffr ies.remove.co.u k> wrote in message
news:pa******** *************** *****@andyjeffr ies.remove.co.u k...
On Tue, 30 Sep 2003 01:37:25 -0400, Phil Powell wrote:
This is where the contention comes in. The client wants it done "FIFO"
(First In First Out) meaning that whoever gets it first will subtract the quantity - but I dispute that (coming from somewhat of a Java background) that since PHP doesn't so single-threading, that means that all four of us could order t-shirts, but the quantity has to reflect that all four of us are ordering (multi-threading).

I dunno, help!


How about the quantity available is the stock quantity (in the product or
stock table) minus the "in basket" quantity (from the basket table). That
way the stock is available and allocated to people. When your baskets
expire (as per your other post) the record that allocates them will be
deleted and hence your stock will then be available for other people.

This means that RG would have to keep doing this every time his basket
expired. If you shorten your expiry time (I would say 24 hours is too
long) it makes it very unfeasible to do what RG suggests (and if someone
writes a script to hit your server every few hours you can block them).

As some advice I would set baskets to expire after 1-2 hours of inactivity
and have every page on your site update the basket time when hit. That
way if the person is still actively looking around your site the basket
expiry will be refreshed and if they leave it won't hang around for long.

You could also give people the option to "Save my basket for later" which
would then put the expiry date 10 years in the future. However, this
opens you back up to RG's attack *.

Most web customers are very quick to jump ship. If they find something
they like they'll buy it. If they actually go to the effort to put it in
their basket they will buy it there and then, unless something makes them
leave the site - when they return virtually no customer would expect their
basket to still be there (would you in a traditional shop?).

And finally, in answer to your earlier post - yes I have "some" (<g>)
experience of writing shopping basket systems.

Cheers,
Andy
* Meaning the attack that RG suggested, not that RG will actually be
attacking your server. :-)


You make me sound like a menace, I'm not, honestly ;P
RG

Jul 17 '05 #4
On Tue, 30 Sep 2003 10:25:17 +0100, RG wrote:
* Meaning the attack that RG suggested, not that RG will actually be
attacking your server. :-)


You make me sound like a menace, I'm not, honestly ;P


That's not what I heard over on alt.l33t.haxor2 ! :-)

Cheers,
Andy
Jul 17 '05 #5
I go to the shop and put the entire stock into my basket, however, I might
be doing this legitimately, meanwhile, I am going around in the shop buying
other stuff. Another legit shopper goes in and purchases just ONE item.
When I later on go to checkout with all 30 items, I of course will have a
problem; I am purchasing 30 items but 29 are only in stock because someone
else just bought one.

That CAN actually happen, so then I would have to follow my current path. :(

Phil

"RG" <Me@NotTellingY a.com> wrote in message
news:3f******** *************** @mercury.nildra m.net...

"Phil Powell" <so*****@erols. com> wrote in message
news:eF8eb.2567 2$sp2.7183@lake read04...
You have ordered one item and placed it into your cart. Let's say you
ordered one small black t-shirt. Your cart will have the product_id,
color_id and size_id for the small black t-shirt. The quantity of this

item
is, let's say 30. You have one in your cart, so how many are available:

1) 29
2) 30

Now let's say that while I ordered one small black t-shirt, Sven ordered 1 small black t-shirt, Anders ordered one black t-shirt, and Olov ordered

one
black t-shirt. If all four of us, at one time, are all ordering the same item and putting it into our carts, how many should there be available to us:

1) 26
2) 25
3) 29
4) 30

This is where the contention comes in. The client wants it done "FIFO"
(First In First Out) meaning that whoever gets it first will subtract the quantity - but I dispute that (coming from somewhat of a Java background) that since PHP doesn't so single-threading, that means that all four of us could order t-shirts, but the quantity has to reflect that all four of us are ordering (multi-threading).

I dunno, help!

Phil

You gonna go round in circles here mate.
What are the chances of multiple people buying the same item in a short
period?
WHat you should do is subtract from the qty when the trtansaction is
complete.

This is why you do not want to follow your current path:
Scenario: I go to your shop and put your entire stock into my basket.
This would stop any legit shopper from being able to put anythin in there
basket.

Just reduce qty when transaction is successful
Hope this helps
RG

Jul 17 '05 #6
RG

"Phil Powell" <so*****@erols. com> wrote in message
news:WHdeb.2728 9$sp2.2015@lake read04...
I go to the shop and put the entire stock into my basket, however, I might
be doing this legitimately, meanwhile, I am going around in the shop buying other stuff. Another legit shopper goes in and purchases just ONE item.
When I later on go to checkout with all 30 items, I of course will have a
problem; I am purchasing 30 items but 29 are only in stock because someone
else just bought one.

That CAN actually happen, so then I would have to follow my current path. :(
Phil


What you need to do then is check that the qty ordered tallies up with the
users basket at CHECKOUT.
Tell the user that they can only have 29
RG

Jul 17 '05 #7
RG

"RG" <Me@NotTellingY a.com> wrote in message
news:3f******** *************** @mercury.nildra m.net...

"Phil Powell" <so*****@erols. com> wrote in message
news:WHdeb.2728 9$sp2.2015@lake read04...
I go to the shop and put the entire stock into my basket, however, I might be doing this legitimately, meanwhile, I am going around in the shop buying
other stuff. Another legit shopper goes in and purchases just ONE item.
When I later on go to checkout with all 30 items, I of course will have a problem; I am purchasing 30 items but 29 are only in stock because someone else just bought one.

That CAN actually happen, so then I would have to follow my current

path. :(

Phil

Ignore previous post.

At checkout, check that there is enough stock to cover the order. If there
isn't tell the user.
RG

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
2286
by: WindAndWaves | last post by:
Hi Folks I am working with a session and a 'cart' (note that I do not really know what I am doing though). I was wondering if there is some easy way (function) to work out how many items I have in my 'basket' / 'cart', because then I could call this function from anywhere to show the user just how many items are on order TIA - Newbie Nicolaas
2
1384
by: Shell | last post by:
What is the best way to store the items and quantities that customers have chosen across a session without using cookies The customer does not need to login to do online shopping and users will be prompted to enter shipping information when they proceed to checkout Any input will be very much appreciated! Thanks!
3
1631
by: Don Grover | last post by:
USing ASP, MSSql on W2k3 I am worried of accumulated old cart product selections from expired browser windows or other unforseen events. I am holding selected productID's & quantities & userID & sessionID in a sql table from a shopping cart. I allow user to clear their cart from a button and also automatically clear their cart on user logon. Also on checkout I clear their cart.
3
2927
by: help | last post by:
please i need help. I am doing a wed site online shopping system for my school project, which requires some asp coding using vb script. I am new to asp and have no knowledge whatsoever on how to code what i need. Please please please could someone please provide me with help, or coding on how to add item details into a basket record, once the user clicks the add to basket link. *** Sent via Developersdex http://www.developersdex.com...
0
880
by: MattB | last post by:
Hi. I have an ecommerce application that has a shopping cart as many do. I've created a way to automatically add other items to the cart if certain items are added, like "Get a fee t-shirt if you buy this" kind of stuff. The DataTable that holds the cart items has a column for "ID" (primary key) and parentID that references another item's ID for items added with another, so they can be lumped together. This lets me delete both the main...
9
2590
by: Rob Meade | last post by:
Hi all, Ok - so I've got the array thing going on, and the session thing going on, and up until now its all been ok. I've got my view basket page which is displaying 3 rows (as an example) - I have an input box on each row enabling the user to update the quantity. If the enter a zero I need to remove the item from the array....
15
4299
gregerly
by: gregerly | last post by:
Hello, I once again turn to this community of genius' for some help with a problem. I've got a shopping cart (which is working well so far) that I will be implementing all kinds of AJAX functionality on. However, first I want to make sure it works if javascript is not available. So when your on the shopping cart page, you can update the quantities then click Update Cart, which would update the totals, and refresh the shopping cart page,...
1
1111
by: vozzek | last post by:
Hi everyone, For the past four months I've been working on a retail website. Built it from scratch, including the shopping cart, which uses a mySQL database indexed by session id. All the pages in the site are php. Everything was running smoothly, until I installed the credit card payment code. I opened a merchant account with Linkpoint and they supplied the gateway. I didn't like the Firefox "your data is unencrypted" warning messages...
4
6268
by: chrism | last post by:
Hello, I'm hoping someone can help me out here. I'm building a shopping cart using sessions, populating with $_POST values from a form. Code abbreviated below: check if form is submitted. if so, set up variables: $name = $_POST; $ribbon = $_POST;
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10113
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.