Zen Cart Logo
Forums / Managing Customers and Orders / How can I limit one items quanity as one per customer?

How can I limit one items quanity as one per customer?

Views: 14,099

Results 1 to 19 of 19
12 Aug 2009, 4:01 PM
#1
attroll avatar

attroll

Zen Follower

Join Date:
Dec 2007
Posts:
103
Plugin Contributions:
0

How can I limit one items quanity as one per customer?

I want to sell an item as a one time sale in my store but I want to limit this one item. I only want to sell one per customer. Everything else in the store they can purchase as many as they want.

Any help would be appreciated.

12 Aug 2009, 5:54 PM
#2
mutester avatar

mutester

New Zenner

Join Date:
May 2009
Location:
Bogota, Colombia
Posts:
28
Plugin Contributions:
0

Re: How can I limit one items quanity as one per customer?

if you go into your catalog, than categories, select the product you want to limit, you will find an option "Product Qty Maximum:"

If you set this to "1" the customer should only be allowed to buy one of this specific product...

12 Aug 2009, 6:16 PM
#3
attroll avatar

attroll

Zen Follower

Join Date:
Dec 2007
Posts:
103
Plugin Contributions:
0

Re: How can I limit one items quanity as one per customer?

Thank you very much.

13 Aug 2009, 3:39 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I limit one items quanity as one per customer?

NOTE: that prevents more than 1 per order but will not stop them from buying again in another order ... is that a problem? :unsure:

13 Aug 2009, 4:23 PM
#5
attroll avatar

attroll

Zen Follower

Join Date:
Dec 2007
Posts:
103
Plugin Contributions:
0

Re: How can I limit one items quanity as one per customer?

Ajeh:

NOTE: that prevents more than 1 per order but will not stop them from buying again in another order ... is that a problem? :unsure:
Yes it could be a problem. Is there any other way of doing it without going in and doing some coding?

13 Aug 2009, 5:35 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I limit one items quanity as one per customer?

Afraid not ... in order to check that the customer only buys 1 for forever ... you would need to add some custom code to check the orders_products table for the customer to see if the product is already ordered and if so, disable the Add to Cart for it ...

This is not impossible to do, but it will require custom coding ... have you got your coder's hat on? :smartalec:

14 Aug 2009, 11:08 AM
#7
demiurgia avatar

demiurgia

New Zenner

Join Date:
Jul 2007
Posts:
88
Plugin Contributions:
0

Re: How can I limit one items quanity as one per customer?

Would there be a way to set this as a default so it dopesn't have to be manually done with each new product. i have had 2 orders this week with customers ordering the same product twice[and they are digital products]. I have default as no quantity box so they must have placed in the same cart twice. I would love to be able to set so they cannot order more than 1.

14 Aug 2009, 1:28 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I limit one items quanity as one per customer?

Again, you would need to customize the code to check the customer's previous orders to see if a product has been purchased before ...

Are you trying to prevent the customer from buying more than once just because it is dumb? Or is there another reason that you need to do this? :smile:

14 Aug 2009, 1:46 PM
#9
demiurgia avatar

demiurgia

New Zenner

Join Date:
Jul 2007
Posts:
88
Plugin Contributions:
0

Re: How can I limit one items quanity as one per customer?

Thanks for your reply. I am only trying to limit it in one order. And just because they are dumb lol and it is a pain to have to refund through paypal and then contact the customer. I have several designers selling in my store and if it is something they have to change when they upload products they will often forget. Would just be great if I could set it as a default in a similar way to being able to set so I don't show a quantity box.

14 Aug 2009, 2:33 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I limit one items quanity as one per customer?

To limit a Product to quantity 1 in the current order you can set the Maximum to 1 ... this is a built in feature of Zen Cart ... :smile:

15 Aug 2009, 12:06 AM
#11
demiurgia avatar

demiurgia

New Zenner

Join Date:
Jul 2007
Posts:
88
Plugin Contributions:
0

Re: How can I limit one items quanity as one per customer?

Ajeh:

To limit a Product to quantity 1 in the current order you can set the Maximum to 1 ... this is a built in feature of Zen Cart ... :smile:

Thanks very much. I know I can restrict the maximum to 1 when I am adding the product in categories/ products.
The default in my store however shows as

Product Qty Minimum: 1
Product Qty Maximum: 0 0 = Unlimited, 1 = No Qty Boxes
Product Qty Units: 1

Product Qty Min/Unit Mix: Yes

So each product I would need to change the maximum to 1. Is there a way to change this default to 1 ?
I do have 'Products Quantity Box Shows:' set at No, Do not show Quantity Box by default [set through configuration /product listing] so only the add to cart button shows and no quantity.

15 Aug 2009, 3:59 AM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I limit one items quanity as one per customer?

You would need to customize the module in the admin for the:
collect_info.php

for the product type you are using ...

15 Aug 2009, 4:21 AM
#13
demiurgia avatar

demiurgia

New Zenner

Join Date:
Jul 2007
Posts:
88
Plugin Contributions:
0

Re: How can I limit one items quanity as one per customer?

thank you again I will have a look and play around and see what i can do.

23 Sep 2009, 2:35 AM
#14
shaztesting avatar

shaztesting

New Zenner

Join Date:
Jun 2009
Posts:
71
Plugin Contributions:
0

Re: How can I limit one items quanity as one per customer?

I have just come accross a bug with this and i don't know how hard it is to fix.

This method (Max Quanitity =1) works when the user is already logged in and within the same session. For example, if the cart has 'product A' and user tries to add that product again, the action is prevented and the following error message appears:
"The quantity added to your cart has been adjusted because of a restriction on maximum you are allowed. See this item: product A"

However, if the 'product A' was added to the cart in a previous session, the store allows the user to add a second product A even when the max quantitiy value is set to 1. For example the user is logged out but their account already holds 'product a' in their shopping cart. The user adds another 'product a' while in the visitor's cart and seeks to checkout. They are then prompted with a login request and when complete they now have 2 of 'product a' with the following message:
"NOTICE: For your convenience, your current shopping cart has been combined with your shopping cart from your last visit. Please review your shopping cart before checking out."

  1. How hard is it to fix this bug? So that the store check's whether product max quantity is reached before merging the visitor cart and the user cart?

  2. I tried adding customer shop status from '0' to '1' or '2' to force a login before they have a chance to add a second 'product a' but that causes more issues. Namely, my customers are directed to the store from my site using a simple form (<form action="http://domain.com/index.php?main_page=product_info&cPath=3&products_id=77&number_of_uploads=0&action=add_product" method="post" enctype="multipart/form-data"> ) which prefills attribute values and chooses the product. Now by forcing a login before adding to the cart, all the form data is lost and the users see a 'Shopping cart empty' message. Is there anyway that the login page doesn't loose all that data?

I think the first option is in the right direction as it fixes the problem for good. I would appreciate any help in the matter.

Thanks in advance,
Shaztesting

23 Sep 2009, 2:30 PM
#15
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How can I limit one items quanity as one per customer?

I cannot reproduce this ...

I login and add a Max 1 product to cart ...

I logout and add the same Max 1 product to cart ...

I login and it says it merged cart ... but I still have quantity 1 ...

What version of Zen Cart are you using?

If Zen Cart v1.3.8 have you applied the Known Bug Fixes?
http://www.zen-cart.com/forum/showthread.php?t=82619

18 Mar 2010, 8:04 AM
#16
chrismarie avatar

chrismarie

New Zenner

Join Date:
Apr 2009
Location:
Chicago, IL
Posts:
45
Plugin Contributions:
0

Re: How can I limit one items quanity as one per customer?

I know this thread is kind of old, but it's the most relevant to my question, so I'm going to give it a shot:

I managed to prevent logged in users from adding an item to their cart if they've already purchased the maximum, but if they add the items when they're not signed in and then log in to complete their purchase, they beat the system.

So my question is: what file would I need to modify to pull items out of the cart when they've already made it to the checkout page?

I'm using Fast and Easy Checkout if that makes a difference. If someone is on the checkout page when they log in, it brings them right back to where they left off.

For anyone who needs to just block people from adding an already maxed out item to their cart, this is what I did...

Since all my products have a download attribute and you have to go through the product info page, I put the booby trap there.

In the pages/product_info/header_php.php file, I added this toward the top:

$query_max = "select SUM(op.products_quantity) as total_qty 
		from " . TABLE_ORDERS . " o, " .
                   TABLE_ORDERS_PRODUCTS . " op 
		where	o.orders_id = op.orders_id
		and		o.customers_id = '" . $_SESSION['customer_id'] . "'
		and		op.products_id = '" . (int)$_GET['products_id'] . "'";

$max = $db->Execute($query_max);
$quantity_purchased = $max->fields['total_qty'];

And in then on the tpl_products_info_display.php page, in the add to cart section, right after

<?php
if (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') {
  // do nothing
} else {
?>

I added this:

<?php if (($products_quantity_order_max != '0') && ($products_quantity_order_max <= $quantity_purchased) && ($products_quantity != '0')) {
echo zen_image_button(BUTTON_IMAGE_MAXED_OUT, BUTTON_MAXED_OUT_ALT) .'<div class="sorryText">You\'ve already bought the maximum allowed for this deal, but don\'t worry, there are plenty more to enjoy!</div>';
	} else {

and don't forget to add an extra one of these bad boys before eof Add to Cart Box ```

<?php } ``` to close the if else statement. I'm going to tweak the shopping cart class to update the quantity if someone's trying to make a new purchase where the quantity is within the per session max, but would put them over the per cart max - I'll post that code when I finish. I'm using v1.3.8a btw
11 Apr 2010, 11:24 AM
#17
arunkarthik avatar

arunkarthik

New Zenner

Join Date:
Mar 2010
Location:
Ooty, India
Posts:
40
Plugin Contributions:
0

Re: How can I limit one items quanity as one per customer?

Thanks a lot zenners this 's wat i was hunting for!!!!!!!!!

:clap::clap::clap:

27 Mar 2011, 4:50 PM
#18
carolc avatar

carolc

New Zenner

Join Date:
Jan 2011
Posts:
11
Plugin Contributions:
0

Re: How can I limit one items quanity as one per customer?

MUtester:

if you go into your catalog, than categories, select the product you want to limit, you will find an option "Product Qty Maximum:"

If you set this to "1" the customer should only be allowed to buy one of this specific product...

Is there a way to default this field to "1"? All items on my site are for download, so if they order more than one it would be by mistake.

18 Apr 2011, 12:27 AM
#19
cycochuck avatar

cycochuck

New Zenner

Join Date:
Jan 2010
Posts:
42
Plugin Contributions:
0

Re: How can I limit one items quanity as one per customer?

chrismarie:

I know this thread is kind of old, but it's the most relevant to my question, so I'm going to give it a shot:

I managed to prevent logged in users from adding an item to their cart if they've already purchased the maximum, but if they add the items when they're not signed in and then log in to complete their purchase, they beat the system.

So my question is: what file would I need to modify to pull items out of the cart when they've already made it to the checkout page?

I'm using Fast and Easy Checkout if that makes a difference. If someone is on the checkout page when they log in, it brings them right back to where they left off.

For anyone who needs to just block people from adding an already maxed out item to their cart, this is what I did...

Since all my products have a download attribute and you have to go through the product info page, I put the booby trap there.

In the pages/product_info/header_php.php file, I added this toward the top:

$query_max = "select SUM(op.products_quantity) as total_qty
from " . TABLE_ORDERS . " o, " .
TABLE_ORDERS_PRODUCTS . " op
where o.orders_id = op.orders_id
and o.customers_id = '" . $_SESSION['customer_id'] . "'
and op.products_id = '" . (int)$_GET['products_id'] . "'";

$max = $db->Execute($query_max);
$quantity_purchased = $max->fields['total_qty'];

> 
> And in then on the tpl_products_info_display.php page, in the add to cart section, right after
> ```
<?php
if (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') {
  // do nothing
} else {
?>

I added this:

<?php if (($products_quantity_order_max != '0') && ($products_quantity_order_max <= $quantity_purchased) && ($products_quantity != '0')) { echo zen_image_button(BUTTON_IMAGE_MAXED_OUT, BUTTON_MAXED_OUT_ALT) .'<div class="sorryText">You\'ve already bought the maximum allowed for this deal, but don\'t worry, there are plenty more to enjoy!</div>'; } else { ``` > > and don't forget to add an extra one of these bad boys before eof Add to Cart Box ``` <?php } ``` to close the if else statement. > > I'm going to tweak the shopping cart class to update the quantity if someone's trying to make a new purchase where the quantity is within the per session max, but would put them over the per cart max - I'll post that code when I finish. > > I'm using v1.3.8a btw Have you made any progress on this? I tried your code on 1.3.9h without FEC and it does not stop the user from ordering multiple. I would like to get this working because I would like to offer a Free Sample per customer on my cart, and to me using a coupon code to do it is a lame and lazy way to do it.