# Maximum quantity of any item per transaction

Thread began 4/18/2011 10:01 am by marovios@yahoo.com | Last modified 4/25/2011 7:26 am by Jason Byrnes | 1078 views | 5 replies |

## 4/18/2011 10:01 am  |  #1 marovios@yahoo.com

### Maximum quantity of any item per transaction

Hi all, I have an unusual question.
I need to limit the quantity of any item being purchased to 40 per transaction.

A sample scenario would be like this: I'm a user and I purchase 12 items of one product, another 12 from another product and 16 from a third product. I end up with 40 items total. In this case I can continue to check out. But, if I try to purchase more than 40 items I should be stopped by the system. As a user I shouldn't be allowed to purchase more than 40 items (of any products, that doesn't matter) on the same order. If I need to purchase 45 items for example, then I should place an order for 40 items and then another order for 5 items.

Is this possible? I guess I would have to deal with the "Total of Quantity" session if it exists, am I right here? How can I achieve this?

Thanks much!.

## 4/18/2011 12:08 pm  |  #2 Jason ByrnesWebAssist

on the cart page, add an if statement around the checkout button to check the c=total cart quantoty and only show the checkout button if the quantity is 40 or less:

php:
``````<?php if(\$<your cart name>->TotalColumn("Quantity") <= "40") { ?>
<checkout button>
<?php } ?>``````

you can use a similar if statement to show an error message if the quantity is greater than 40:

php:
``````<?php if(\$<your cart name>->TotalColumn("Quantity") > "40") { ?>
error message
<?php } ?>``````

in both of these if statements, replace "<your cart name>" with the name of your eCart object.

## 4/18/2011 1:24 pm  |  #3 marovios@yahoo.com

Thanks much for your help Jason. I will give it a try and let you know, seems it's what I have been looking for, a piece of code to handle the max quantity. Thanks!.

you're welcome.

## 4/25/2011 7:11 am  |  #5 marovios@yahoo.com

Just wanted to let you know that your code worked perfectly. Thanks much!!!!

## 4/25/2011 7:26 am  |  #6 Jason ByrnesWebAssist

Great, glad to hear it is working.

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

## Everything else!

Close Window

Account or customer service questions?

Need technical support?

Content

Layout

Ease of use

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 Window

## We were unable to retrieve the attached file

Close Window

### Attach and remove files

• Text Formatting
• Insert Element
• Block Formatting
• Cancel
Close Window

Close Window

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