Solved

VirtueMart 1.1.4 Limit product quantity (front-end)

Posted on 2011-03-20
12
1,034 Views
Last Modified: 2012-05-11
Hello Experts,

I'm looking for possibility to limit products quantity in product fly page. I want to disable option to add more that 3 units per product. Right now customer can type or encreasde quantity by pressing more button. Is it possible to limit this number?
Role: Each time customer typer number bigger than 3 automatycly quantity going to be 3
Role: Each time customer increasing quantity with arrows this possibility locks when he reached 3
Thank you,
Dan
0
Comment
Question by:DanSmir
  • 7
  • 5
12 Comments
 
LVL 13

Expert Comment

by:StormITSolutions
ID: 35187896
This thread details how to do it

http://forum.virtuemart.net/index.php?topic=26750.0

Edit ps_cart.php file located in administrator/components/com_virtuemart/classes/ps_cart.php
  //maximize quantity to 3 
		//edit by Looney
		
		if ($quantity > 3) {
			$vmLogger->Warning( "No more then 3 allowed!" );
			return False;
		}

Open in new window


Add the above before the line

// Check for negative quantity

Storm
0
 

Author Comment

by:DanSmir
ID: 35187983
Hello StormITSolutions,

Thank you for your reply, but unfortunately it not work.
I added code exactly as you explained, but it is still possible to add more than 3 units per product.

Any ideas?

Thank you,
Dan
0
 

Author Comment

by:DanSmir
ID: 35188005
Dear StormITSolutions,
Well, it doing exactly same as VM limit for a product quantity, i want to disable possibility to change values more than 3. Is it possible?
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 13

Expert Comment

by:StormITSolutions
ID: 35188181
The way the above code should work is if they use the arrows to select 4 or type in 4 they get the error message and have to change it back to 3 or under.

BUt I see what you mean you want to force it to change for them.



Try this

 ps_cart.php
else {
			$this->update( $d );
			
		}

Open in new window


Replace it with this

$this->$updated = 1;

Open in new window


Ah actually this wont work it needs an if statement to say

if quantity is >2 update( $d )

if quantity is 3> $updated = 3

Im working on a clients site just now ill see if I can write you a solution when I get some time later

Storm
0
 
LVL 13

Expert Comment

by:StormITSolutions
ID: 35188205
Ah wait I just remembered this was implemented in the 1.1 VM

Go to List Products in the backend of site

Choose Product you want to limit

CLick Product Status

Set Minimum Purchase Quantity:

&

Set Maximum Purchase Quantity:

Sorry about that forgot it was part of it now

Storm
0
 

Author Comment

by:DanSmir
ID: 35188206
Thank you,

I will wait for this.

Sincerely, DS
0
 

Author Comment

by:DanSmir
ID: 35188230
I want to BLOCK possibility to add more that 3 in front page. When customer types 4 it should automatically be changed to 3. That what i mean.

Thanks,
Dan
0
 
LVL 13

Expert Comment

by:StormITSolutions
ID: 35188309
I see what you are suggesting but the last message causes a pop-up to appear informing the user that they can only buy in quantity's of 3.

To do what you are asking doesn't inform the buyer why its changing to 3, which might have the effect that if they want to buy 4 items and will leave the site and buy elsewhere.

But with the pop up you are letting the buyer know why, and the sale can still proceed with 3 products rather than the 4 they want, but that wont then stop them buying another 1 single on a second order.

Why are you limiting it to 3 and what type of product is it as you could change the wording of the pop up so as not to loose the buyer.

I know if I was shopping on line and if I typed 4 it changed to 3  I would assume a glitch on the system and then not want to trust my card details on the site.

Always inform the user why : )

Storm
0
 

Author Comment

by:DanSmir
ID: 35188441
Well, may be you right. But i want to prevent from customer to add more that it possible. I want my customers make minimum moves on site..
0
 
LVL 13

Accepted Solution

by:
StormITSolutions earned 500 total points
ID: 35188455
OK then were back to the original idea.

$this->$updated = 3;

Would force the quantity back to 3 if they set 4.

But it will also do it for 1 & 2 so it requires an if statement to use it only when needed.

Ill have a look at it later : )

Storm
0
 

Author Comment

by:DanSmir
ID: 35188668
Thank you. I will not close this question yet.
0
 

Author Closing Comment

by:DanSmir
ID: 35309576
Thank you for your time
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question