close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

stock in order

Thread begun 10/27/2009 11:11 am by alhero_94375722 | Last modified 7/20/2010 2:05 pm by Eric Mittman | 5062 views | 17 replies |

alhero_94375722

stock in order

hi
if i have in my data base qty in stock
i want check qty in stock is apply or not
example
coustomer need 5 pic from mobile but i have only 4 mobile in my stock

another proplem Lets say there's a product with the quantity = 1 . what happens when 2 customers buy it at the same time? I mean there should be a way to reserve that product when ever a user adds it to his shopping cart.


how i do this

Sign in to reply to this post

Eric Mittman

You can implement a check for the quantity that the user is choosing but it is a custom solution and will require custom coding. One way you could do this would be to have some server side validations in place that check the posted quantity against the available quantity in your db. If the entered amount exceeds the available amount then you should not add the item to the cart and display an error message to the user instead.

The second scenario you described is a little different. For this one you would need to have some temporary field in the table that holds the value that a user has added to the cart. This way when a user adds the item to the cart it would effectively reduce the available quantity so that another user would see an error when trying to add too many.

Both of these scenarios are quite custom though and are not supported features of eCart. If you have questions about the overall process I can try to give you some advice on things but I will not be able to offer in depth support of this custom solution.

Sign in to reply to this post

alhero_94375722

Originally Said By: Eric Mittman
  You can implement a check for the quantity that the user is choosing but it is a custom solution and will require custom coding. One way you could do this would be to have some server side validations in place that check the posted quantity against the available quantity in your db. If the entered amount exceeds the available amount then you should not add the item to the cart and display an error message to the user instead.
.  



very thanx but can i have some help to how i make this validations .

Sign in to reply to this post

Eric Mittman

To incorporate this type of server validation you will need to make sure you have a recordset on the page that pulls the stock value from your db. This recordset will need to be above the validation code.

Once the recordset is in place you will add in the validation. The validation will be a number validation. For the value use the lightning bolt to select the quantity field then add the validation. You can leave the minimum at 0 but for the max you want to use the value from your recordset for the stock level. I'm including a screen shot of what this validation looks like when configured in the interface.

So long as this recordset occurs before the validation does then this should work for you. One other thing is the validation trigger, it should be setup like you add to cart, probably the button pressed trigger.

Sign in to reply to this post

dlovas275157

Eric,

I am attempting to set up a WA Server Validation to prevent adding more to cart than in stock (as discussed in this thread above). I have taken your recommendation to accomplish this through server side validation, but I cannot get it to work properly.

1. Stock Amount is set in my DB as the column "stockAmount" int(11).
2. rsBooks pulls the necessary stockAmount for use on the page by the validation code.
3. My validation code appears to be below the rs code.

Can't seem to determine why it is not working properly. If fails validation all the time (regardless of stockAmount or how many are in cart).

Attached is my code and a few screenshots. Any help is much appreciated.

-D.

Sign in to reply to this post

Eric Mittman

It looks like your validation is comparing the quantity for the first item in the cart to the value from your rs. I don't think that this is how you want to have this setup. Instead you should be comparing the value in the db to the posted quantity value from the form, the same value that you are binding to the quantity on the add to cart. This is so that you are comparing what is attempted to be added to the cart with what is available in your db.

Sign in to reply to this post

CraigRBeta Tester

server validation

Hi all,

i just did this another way and was interested in the outcome of this thread.
I didn't use server validation, (this time), I assume I would need CSS form builder to do this ??

Anyway here's my approach, no server side validation required.

Having retrieved my stock value from the appropriate recordset, in the block of code beginning near // WA eCart AddToCart...

After the first line checking that the form has been submitted. add a new 'if' block, something like this, where Cartname is the name of your cart.
Also add a line, setting a variable to false just before this block, (existing code is shown in grey)...

$stockwarning = false;// resets the stock warning message to false

// WA eCart AddToCart
if (isset($_POST["Cartname_1_ATC"]) || isset($_POST["Cartname_1_ATC_x"])) {


if($row_rsStockLookup['StockQty'] < $_POST["rugsntack_1_Quantity_Add"]) { ) {//row from recordset value compared to qty entered into add to cart form
$stockwarning = true;
}
else
{//do the cart code

$ATC_itemID = $_POST["Cartname_1_ID_Add"];...



You also need to add an extra closing bracket at the end of this block, about 25 lines down.

When the 'add to cart' form is posted, if the stock level is below the item quantity value, the $nostock variable is set to true, and the add to cart code is not processed, hence the page is not redirected.

You can then show a message somewhere on your page, such as
<?php if ($stockwarning == true) {
echo 'Message to customer';
} ?>

Sign in to reply to this post

dlovas275157

Eric,

I have changed my validation rule as you indicated (I hope I have followed correctly). However I am still having issues. It will allow me to add as many as I want and never fails validation.

Attached is my code and screenshots.

Any help is much appreciated. -D

Sign in to reply to this post

dlovas275157

Craig R,

I am attempting your method as well (exploring both solutions), but my page has a syntax error and loads blank. I am having trouble determining what is wrong. Could you look at my code and see what may be wrong. Attached is code.

Ultimately, I would like to get this to work both ways since I have multiple projects requiring similar checks and would like to understand both methods. I do not mind using Server Side Validation at all.

D.

Sign in to reply to this post

Eric Mittman

I'm a little confused by the setup that you currently have. It looks like you are hard coding the quantity to 1 in your add to cart server behavior. You should instead have a quantity text field in your add to cart form that allows the user to enter the stock they would like.

Then you would compare this posted value to the stock in the db with the check that you are doing. Currently you are setting the value of the form element for the stock amount to the value from your recordset, then you are checking these values in the validation. Since they are always the same the validation will never fail. The check is ok, you just need to allow the user to enter their own amount so that it will trigger the validation if they enter an amount that is greater than what you have.

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