Solved

VirtueMart 1.1.4 Limit product quantity (front-end)

Posted on 2011-03-20
12
1,032 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
 
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now