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

rating

HELP! - How to reduce Stock by the quantity purchased

Thread began 5/20/2011 1:45 pm by hbibizadeh396670 | Last modified 6/03/2016 2:20 pm by Ray Borduin | 26381 views | 18 replies |

hbibizadeh396670

HELP! - How to reduce Stock by the quantity purchased

I have a numeric value in my products table which represents product stock.

When a user makes a purchase, can you tell me how to reduce this value by the quantity purchased.

Thank you in advance

Sign in to reply to this post

hbibizadeh396670

To explain further, I just need simple stock management.

Sign in to reply to this post

Jason ByrnesWebAssist

This is not supported by eCart, it takes hand coding to accomplish.

you would need to hand code a loop through the cart contents, and update the quantity based on the cart ID inside the loop:
<?php
while (!$yourCart->EOF()) {
<update script here>
$yourCart->MoveNext();
}
$yourCart->MoveFirst();
?>

Sign in to reply to this post

hbibizadeh396670

Could you please correct my script as it’s is giving me an error message.

Also, could you tell me what page to put it on, and in what part of the code? For example, should it be on the pp_checkout_success.php and in between the head or body tags.


<?php
while (!$eCart->EOF()) {
<($ProductStock = ($ProductStock - $DetailQuantity))>
$eCart->MoveNext();
}
$eCart->MoveFirst();
?>

Sign in to reply to this post

hbibizadeh396670

I don't know what I am doing wrong I just can not make it work?

Sign in to reply to this post

hbibizadeh396670

Could you tell me how to make this code work

<?php
while (!$eCart->EOF()) {
<($ProductStock = ($ProductStock - $DetailQuantity))>
$eCart->MoveNext();
}
$eCart->MoveFirst();
?>

Sign in to reply to this post

hbibizadeh396670

Do you offer any documentation on setting up inventory?

It is vital that I have some sort of inventory control because I cannot afford to sell products I don’t have.

I have not got enough knowledge of PHP to develop this code, so I would appreciate some help.

Sign in to reply to this post

Jason ByrnesWebAssist

like I stated initially, this is not supported in eCart, we cannot offer support for this including correcting your code.

if you need assistance, you should either sign up for a premiere ticket where we can work with you on a one to one basis, or submit a request on the job forum to see if one of the community experts can help you with this.

Sign in to reply to this post

hbibizadeh396670

I think that I am very close. I know you said that you would not help me write the code. Could you just point me in the right direction? I have tried & tested this code. And I am not sure why it does not deduct the stock value.

Is there something obvious in this that I have done wrong.

Again this is very important to me and I hope you can help me.


<?php
while (!$eCart->EOF()) {
mysql_select_db($database_siteezy_ecart2, $siteezyecproducts);
$query_itemQ = "Update Products SET Products.ProductStock = Products.ProductStock -
$DetailQuantity WHERE Products.ProductID = $idCall";
$itemQ = mysql_query($query_itemQ, $siteezyecproducts) or die(mysql_error());
$eCart->MoveNext();
}
$eCart->MoveFirst();
?>

Sign in to reply to this post

Jason ByrnesWebAssist

i dont see anything obvious wrong with the code, I would start by editing this line:

php:
$query_itemQ = "Update Products SET Products.ProductStock = Products.ProductStock -

$DetailQuantity WHERE Products.ProductID = $idCall";



to:

php:
$query_itemQ = "Update Products SET Products.ProductStock = Products.ProductStock -

$DetailQuantity WHERE Products.ProductID = $idCall";
echo("SQL: ".$query_itemQ."<br>");



this will write the query being executed to help troubelshoot, but really you are asking me here to support something that I have already told you is not supported.

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