close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Inventory control in eCart5

Thread began 4/06/2010 1:48 pm by Badger | Last modified 7/15/2010 1:44 pm by Badger | 3352 views | 28 replies


Here is how I have setup my checkout_success.php page to update my inventory database table upon successful transaction/purchase. I am using eCart 5.

1. In my inventory table, I have a column called "stockAmount". It is set up as int(11) default=1 null=yes. This column holds a numeric number that is representative of how many of the product I currently have in stock. In my case, I set the default to 1 since my website is selling rare books that only typically have 1 copy available at a time.

2. I edited my eCart Object to add a column for "stockAmount". Name: stockAmount, OutputType: number, Unique: no

3. I added the following calculation to my eCart Object. Name: subtractions, Output type: text, calculation formula: [stockAmount]-[Quantity]

4. On my checkout_success.php page, i made sure I had a require_once at the top to connect to my database as follows: <?php require_once('../Connections/myConn.php'); ?>

5. Then, directly before the image in the cart display on my checkout_success.php page, I added this code:

$FinalStack = $hbCart->DisplayInfo("subtractions");
$idProduct = $hbCart->DisplayInfo("ID");

$varCurrentTimestamp = $_SERVER["REQUEST_TIME"];

//mysql_select_db($database_hbConn, $hbConn);
$query_subtractions = "UPDATE hb_inventory SET stockAmount = $FinalStack, publish = 'N', featured = 'N', sold = 'Y', dateModified = $varCurrentTimestamp WHERE id_inventory = $idProduct" ;
$subtractions = mysql_query($query_subtractions, $hbConn) or die(mysql_error());

This effectively makes the following changes upon checkout success:

stockAmount is reduced by 1
publish is changed from Y to N unlisting the item from the website
featured is changes to N
sold is changed to N
dateModified is updated with the current unix timestamp

These changes are looped through all items in the order.

This code was adapted from Sade's code notes in this thread above. Thanks Eric/Sades for you help. I appreciate it.


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





Ease of use


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...