Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Reducing Quantities as Items ordered?

LEGEND ,
Feb 23, 2009 Feb 23, 2009
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
TOPICS
Server side applications
367
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 23, 2009 Feb 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 23, 2009 Feb 23, 2009
LATEST
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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines