Skip to main content
Inspiring
February 23, 2009
Question

Reducing Quantities as Items ordered?

  • February 23, 2009
  • 2 replies
  • 367 views
I had a request from a client to have the cart reduce the total quantity
available when a product is sold. So if I have a total of 5 items
available and the customer buys 2, the total would be 3 left over after

I suspect that this is done with Store Procedures.

I've been doing this stuff for a while but with new things, I have a
hard time getting my head around it; could you explain with that in
mind? Thanks

Also, do you have code that would demonstrate how this is done?

Thanks
This topic has been closed for replies.

2 replies

Inspiring
February 23, 2009
pdate:
>
> UPDATE items
> SET stock = stock - qtysold
> WHERE item = itemfromcart
>
> You could also do this when the items have shipped, which would avoid
> any problems.
>
> Dooza
Thanks
Inspiring
February 23, 2009
Art wrote:
> I had a request from a client to have the cart reduce the total quantity
> available when a product is sold. So if I have a total of 5 items
> available and the customer buys 2, the total would be 3 left over after
>
> I suspect that this is done with Store Procedures.
>
> I've been doing this stuff for a while but with new things, I have a
> hard time getting my head around it; could you explain with that in
> mind? Thanks
>
> Also, do you have code that would demonstrate how this is done?
>
> Thanks

Hmm, yes, a stored procedure would work, I think.

What your doing needs to be looped. You take your response from your
payment gateway which says the money has been taken, then loop through
the cart, adjusting the stock levels accordingly. Your just doing an update:

UPDATE items
SET stock = stock - qtysold
WHERE item = itemfromcart

You could also do this when the items have shipped, which would avoid
any problems.

Dooza
--
Posting Guidelines
http://www.adobe.com/support/forums/guidelines.html
How To Ask Smart Questions
http://www.catb.org/esr/faqs/smart-questions.html