Post by cashman9 » Wed Dec 01, 2010 1:18 am

I would like to find out if there is a way to limit selling an one item per customer. For example, lets say the price is really low for some product since its on promotion. How do I limit the sell that it would be LIMIT 1 PER CUSTOMER order?

Thanks!

Active Member

Posts

Joined
Wed Nov 17, 2010 4:28 am

Post by cashman9 » Wed Dec 01, 2010 3:49 am

anyone?

Active Member

Posts

Joined
Wed Nov 17, 2010 4:28 am

Post by Qphoria » Wed Dec 01, 2010 4:20 am

I suppose a similar concept to the "min qty" would be needed for max qty. It is odd to ever do this which is why I didn't add it.. cash is green no matter who it's from... but i digress

A quick mod would be to use the Location field or Cost field (since it is not used for anything programmatically) and pretend it is the max qty field. Put a number like 1 in that location field or cost field

Then
1. EDIT: system/library/cart.php

2. FIND:

Code: Select all

'minimum'      => $product_query->row['minimum'],
3. AFTER, ADD:

Code: Select all

'location'      => $product_query->row['location'],
4. FIND (2 PLACES):

Code: Select all

$this->setMinQty();
5. AFTER, ADD (Both places):

Code: Select all

$this->setMaxQty();
6. FIND:

Code: Select all

public function setMinQty() {
7. BEFORE, ADD:

Code: Select all

public function setMaxQty() {
        foreach ($this->getProducts() as $product) {
                if ($product['location'] != '') {
                        if ($product['quantity'] > $product['location']) {
                                $this->session->data['cart'][$product['key']] = $product['location'];
                        }
                }
        }
} 

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by cashman9 » Wed Dec 01, 2010 4:45 am

I'm using location field for Retail Prices, any other way add another location field for this?

Active Member

Posts

Joined
Wed Nov 17, 2010 4:28 am

Post by Johnathan » Wed Dec 01, 2010 5:22 am

You could reverse the minimum quantity field, and flip its greater-than/less-than sign in the code.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by cashman9 » Wed Dec 01, 2010 5:48 am

Johnathan wrote:You could reverse the minimum quantity field, and flip its greater-than/less-than sign in the code.

However, the problem is its for only certain products. Not all products, but that coding will effect all products...

Active Member

Posts

Joined
Wed Nov 17, 2010 4:28 am

Post by Johnathan » Wed Dec 01, 2010 6:42 am

Yes, but you can just set the "minimum" (now the maximum) to something higher (like 99) for the other products.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by cashman9 » Wed Dec 01, 2010 9:48 am

Johnathan wrote:Yes, but you can just set the "minimum" (now the maximum) to something higher (like 99) for the other products.
Maybe there is some other way to work with this issue without changing effects all the products?
Like an option to be added with a check that applies to this specific item.

Active Member

Posts

Joined
Wed Nov 17, 2010 4:28 am

Post by cashman9 » Wed Dec 01, 2010 9:52 am

Qphoria wrote:I suppose a similar concept to the "min qty" would be needed for max qty. It is odd to ever do this which is why I didn't add it.. cash is green no matter who it's from... but i digress

A quick mod would be to use the Location field (since it is not used for anything) and pretend it is the max qty field. Put a number like 1 in that location field

Big companies have limit 1 per customer not to abuse it I guess.

Active Member

Posts

Joined
Wed Nov 17, 2010 4:28 am

Post by Qphoria » Wed Dec 01, 2010 10:46 am

Well i know for retail brick and mortar it makes sense because you want people to come to your store.. the mentality that while they are in your store they will make impromptu purchases of other products.. so you want to keep more people coming to the store... But a website is a different mentality usually.. tho perhaps you are right... I suppose it could be applied the same for big discounts that you want others to look around your store and not leave because the main deal is sold out already. I'll add it to the next version or so

You could also use the "cost" field if that isn't currently used. leave it empty for products you don't want a maxqty set for. I've updated the code above to first check if the field has a value and if not it just ignores it

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by PaulineNMU » Sun Apr 03, 2011 11:06 pm

Exactly what I needed!! Thanks so much!

Newbie

Posts

Joined
Sat Dec 05, 2009 4:59 am

Post by robster » Sun Jul 31, 2011 9:48 pm

This works well but how do I prevent it from showing the quantity to 4 decimal places:

I enter quantity of 5 on product lage in admin but on front it shows 5.000 in cart which doesn't look quite right.

Rob

I know my place...!


User avatar
Active Member

Posts

Joined
Tue Jul 13, 2010 8:08 pm
Location - North Yorkshire, UK

Post by robster » Sun Jul 31, 2011 10:25 pm

Actually scrub that. I changed my chosen field to SKU and it all works fine.

However, now I need to run a query to update all my 2000 products to insert quantity of 1 in SKU field for each product so that I don't have to manually do it. Any ideas what that query should be?

Also, how do I set a default figure of 1 in the SKU field (99.9% of my products are maximum 1 so I want to be able to just change the 0.1% that need a higher maximum on an as and when basis) - for future products.

Cheers

Rob
Last edited by robster on Tue Sep 20, 2011 4:42 pm, edited 2 times in total.

I know my place...!


User avatar
Active Member

Posts

Joined
Tue Jul 13, 2010 8:08 pm
Location - North Yorkshire, UK

Post by davidkimm » Tue Sep 20, 2011 11:09 am

Yes money is green and the more we sell the better ;D ;D ;D ... but in rare cases we need to limit the quantity of promotional items... so yes min and max are both important...

Using oc v1.5.1.2 and following these instructions to add product field "maximum". Instead of changing "location"... I added new field "maximum". Made the changes to controller, model, admin template, and altered product table for maximum. Field shows up in admin product... and when saved .. saves into database... to test I have one product set at maximum 30... on frontend.. I can still add 30+ to cart...

Steps 4-7... I do not have in my system/library/cart.php ... not sure which version the instructions were for... but obviously somethings changed in version 1.5.1.2 ... any ideas? Not asking for handouts just a little help in the right direction .... thanx :)
Qphoria wrote:I suppose a similar concept to the "min qty" would be needed for max qty. It is odd to ever do this which is why I didn't add it.. cash is green no matter who it's from... but i digress

A quick mod would be to use the Location field or Cost field (since it is not used for anything programmatically) and pretend it is the max qty field. Put a number like 1 in that location field or cost field

Then
1. EDIT: system/library/cart.php

2. FIND:

Code: Select all

'minimum'      => $product_query->row['minimum'],
3. AFTER, ADD:

Code: Select all

'location'      => $product_query->row['location'],
4. FIND (2 PLACES):

Code: Select all

$this->setMinQty();
5. AFTER, ADD (Both places):

Code: Select all

$this->setMaxQty();
6. FIND:

Code: Select all

public function setMinQty() {
7. BEFORE, ADD:

Code: Select all

public function setMaxQty() {
        foreach ($this->getProducts() as $product) {
                if ($product['location'] != '') {
                        if ($product['quantity'] > $product['location']) {
                                $this->session->data['cart'][$product['key']] = $product['location'];
                        }
                }
        }
} 

New member

Posts

Joined
Wed Mar 23, 2011 3:12 pm

Post by robster » Tue Sep 20, 2011 4:41 pm

In my case I am selling ONLY downloads so clearly one of each is all that is needed.

Robster

I know my place...!


User avatar
Active Member

Posts

Joined
Tue Jul 13, 2010 8:08 pm
Location - North Yorkshire, UK

Post by grgr » Wed Sep 21, 2011 3:43 am

davidkimm wrote:Yes money is green and the more we sell the better ;D ;D ;D ... but in rare cases we need to limit the quantity of promotional items... so yes min and max are both important...


Not asking for handouts just a little help in the right direction .... thanx :)
Moved to extenstion store - see later post.
Last edited by grgr on Thu Sep 22, 2011 2:37 am, edited 2 times in total.

Image Image Image Image Image Image Image Image


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by davidkimm » Wed Sep 21, 2011 6:24 am

thanks grgr ;D ;D ..... searched high and low and the few I found were for previous versions... Prefer the vqmod but already started hard coding and got it working....

Compared to the vqmod you supplied... I missed a step in the catalog/controller/checkout/checkout.php also I did the error_maximum a little different. The limited qty item maximum is 30 and for some reason doing it the way below... it did not behave correctly... maybe it was user error... and the db table maximum I have default set at 9999 ...

Code: Select all

				if ($product_info['maximum'] < ($product_total + $quantity)) {
					$json['error']['warning'] = sprintf($this->language->get('error_maximum'), $product_info['name'], $product_info['maximum']);
				}
So I did mine

Code: Select all

				if (($product_total + $quantity) > $product_info['maximum']) {
					$json['error']['warning'] = sprintf($this->language->get('error_maximum'), $product_info['name'], $product_info['maximum']);
				}
Same thing but flip flopped....

Thanks.. it allowed me to check my work.... definitely using the vqmod version for my next project... I don't know about the vqmod but everything was same as the hard code .... which works perfectly on ver1.5.1.2... just to let you know... ;) will post back if there is a problem...

Edit------
I can change the quantity in "shopping cart" and it allows to change regardless of the minimum and maximum set for that product... no warning messages either...

New member

Posts

Joined
Wed Mar 23, 2011 3:12 pm

Post by grgr » Wed Sep 21, 2011 3:14 pm

davidkimm wrote: I can change the quantity in "shopping cart" and it allows to change regardless of the minimum and maximum set for that product... no warning messages either...
Indeed, the default OC install doesn't either, it does however catch it when you hit the checkout button and won't let you continue.

Image Image Image Image Image Image Image Image


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by TML » Wed Sep 21, 2011 11:43 pm

This is a very nice mod to have. Sometimes we give away free samples; one per order.

TML: Time Machine for Linux


User avatar
TML
New member

Posts

Joined
Sat Aug 27, 2011 10:41 pm
Location - Ontario, Canada

Post by grgr » Thu Sep 22, 2011 2:35 am

I've updated this so that it works without a max quantity (uses a 0 as default) and put it in the extension store (free to download).

Two versions 1.5.0.x and 1.5.1.x because there was a slight difference in one of the files and the vQmod wouldn't work.

Again, not entirely tested but it seems to be working OK.

http://www.opencart.com/index.php?route ... on_id=3327

Image Image Image Image Image Image Image Image


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK
Who is online

Users browsing this forum: No registered users and 88 guests