Solved

VirtueMart 1.1.4 Limit product quantity (front-end)

Posted on 2011-03-20
12
1,051 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Read about how to approach blogging and about ways to do it right. Stand out from the crowd and let your knowledge be consumed by a large audience. This article aims to explain how your blog should look like,  the most important things to do while b…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

636 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