Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VirtueMart 1.1.4 Limit product quantity (front-end)

Posted on 2011-03-20
12
Medium Priority
?
1,059 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 14

Expert Comment

by:Allan Nisbet
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 14

Expert Comment

by:Allan Nisbet
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 14

Expert Comment

by:Allan Nisbet
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 14

Expert Comment

by:Allan Nisbet
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 14

Accepted Solution

by:
Allan Nisbet earned 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

876 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