close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Subtract product from inventory on checkout

Thread began 2/02/2011 1:12 pm by eric284736 | Last modified 2/04/2011 7:20 am by Jason Byrnes | 3593 views | 11 replies |

eric284736

Subtract product from inventory on checkout

Hi,

I am using ecart 4.x, coding with .asp.

I have in the product table a column with the max number of items that I start with.
I have a column that would display the current number of that item on hand.

So on the product detail page I could show currently in stock the number of items.

How would I get the cart to subtract the items in the order from the product table and update the current stock level?

It seems there was a thread about this that I had bookmarked from the old forums, but that link is bad now.

thx!
Eric

Sign in to reply to this post

Jason ByrnesWebAssist

You would need to hand code this on the confirm page. After the eCart checkout code, add a loop through the cart items with an update record behavior inside it to update each purchased item based on the product ID in the cart and the Quantity in the cart.

It should not be too difficult to program this if you are comfortable with ASP programing.

Sign in to reply to this post

eric284736

Could I use the DataAssist Multiple update for this?

I would need to write a SQL command to subtract the qty number from the inventory number, is that correct?

sorry for two questions, thanks!

Sign in to reply to this post

Jason ByrnesWebAssist

no, you wont be able to use data assist for this, you will need to hand code the update statements.

Yes, the update code will update the quantity column and subtract the purchased quantity.

Sign in to reply to this post

eric284736

okay, not that good at asp.

what if it is in php?

thx
Eric

Sign in to reply to this post

Jason ByrnesWebAssist

it's the same in PHP as in ASP, you will still need to hand code the logic to loop through the cart and perform the update to the quantity column.

Sign in to reply to this post

eric284736

Thanks Jason. I think I have the idea.

I can take the recordset that the cart already uses:

<%' WA eCart Store Cart Details in Db
if (Request.ServerVariables("Request_Method") = "POST") then
WA_connection = MM_connBBT_STRING
WA_table = "dbo.OrderDetails"
WA_redirectURL = ""
WA_indexField = "DetailOrderID"
WA_fieldNamesStr = "regID|DetailDate|DetailOrderID|DetailItemID|DTitle|Description|Quantity|Day|Time|AttendeeName|Preg|PregTerm|GolfClubs|TennisRac|InventoryORD" .......

And copy that, edit the SQL to subtract the Quanity from the inventory
then loop that recordset with an update behavior in there.

Would I still use the if (Request.ServerVariables("Request_Method") = "POST") then
to have the update post when the submit order button is pressed?

thx
Eric

Sign in to reply to this post

Jason ByrnesWebAssist

Yes, you would still want to use the POST request method as the trigger for the update.

The code you are highlighting is not what you should be using


you really need to create the code by hand to do this.

Sign in to reply to this post

eric284736

okay.

Not sure how to get the cart contents recordset on that page.

Here is the confirm.asp page currently in place.

We had a setup where that went to the success page and this captured the session and ran thru a multiple update to post the new inventory number.

However that code is not correct on the success page so it does not post the incremental numbers.

thx
eric

Attached Files
confirm.zip
success.zip
Sign in to reply to this post

eric284736

Jason - sorry for the slow uptake. Tell me if this is correct:

The update method will be updating each record individually in the loop as opposed to a multi record update where it updates multiple records at once.

Correct?

thx
Eric

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...