Solved

VirtueMart 1.1.4 Limit product quantity (front-end)

Posted on 2011-03-20
12
1,042 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 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
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

 
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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
show child records separated by commas 12 34
php error 27 56
Google Dork query 7 63
php ajax contact form gives me undefined index error upon submission 2 36
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
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.
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 …

756 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