Post by stewiek » Sun Nov 07, 2010 9:12 pm

I am doing wholesale and using opencart for this.

is there anyway I can set the quantity with a dropdown menu?

say a quantity of 5,10,15,20 ?

New member

Posts

Joined
Mon Nov 09, 2009 4:04 pm

Post by billyggla » Mon Nov 08, 2010 3:12 am

You could try this

in /catalog/view/theme/default/template/product/product.tpl

find

Code: Select all

<input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
and change to

Code: Select all

<select name="quantity">
  <option value="<?php echo $minimum; ?>"><?php echo $minimum; ?></option>
  <option value="10">10</option>
  <option value="15">15</option>
  <option value="20">20</option>
</select>
Change the minimum in admin and the option values to the amounts you want
NOTE: this will show for every product.

hope that helps..

Active Member

Posts

Joined
Mon Sep 20, 2010 7:05 am

Post by stewiek » Mon Nov 08, 2010 8:52 am

thanks billy.

unfortunately, there are other items that are 12,24,36

New member

Posts

Joined
Mon Nov 09, 2009 4:04 pm

Post by billyggla » Mon Nov 08, 2010 9:13 am

how about this then..

Code: Select all

<?php $min = '<?php echo $minimum; ?>'; ?>
<?php if ($min = 5) { ?>
<?php echo ?>
<select name="quantity">
  <option value="<?php echo $minimum; ?>"><?php echo $minimum; ?></option>
  <option value="10">10</option>
  <option value="15">15</option>
  <option value="20">20</option>
</select>
<?php } elseif ($min = 12) { ?>
<?php echo ?>
<select name="quantity">
  <option value="<?php echo $minimum; ?>"><?php echo $minimum; ?></option>
  <option value="24">24</option>
  <option value="36">36</option>
</select>
<?php } else { ?>
<?php echo ?>
<input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
<?php } ?>

Active Member

Posts

Joined
Mon Sep 20, 2010 7:05 am

Post by stewiek » Mon Nov 08, 2010 10:12 am

thanks for the reply again.

tested the code. it has
Parse error: syntax error, unexpected ';' in line 103.


the earlier one works flawlessly.

hope you can help. thanks
Last edited by stewiek on Mon Nov 08, 2010 6:30 pm, edited 1 time in total.

New member

Posts

Joined
Mon Nov 09, 2009 4:04 pm

Post by stewiek » Mon Nov 08, 2010 5:29 pm

help anyone?

i made a search and found this:
http://forum.opencart.com/viewtopic.php ... ity#p48602

but catalog/view/theme/YOURTHEME/template/product/product.tpl
doesn't have this code anymore

Code: Select all

<input type="text" name="quantity" size="3" value="1" />
guess its for the older version.

New member

Posts

Joined
Mon Nov 09, 2009 4:04 pm

Post by billyggla » Mon Nov 08, 2010 6:45 pm

sorry about that..
I will have a look at the code i posted.
you can put it back the way it was by replacing the code i posted with this

Code: Select all

<input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />

Active Member

Posts

Joined
Mon Sep 20, 2010 7:05 am

Post by stewiek » Mon Nov 08, 2010 6:58 pm

Thanks for helping out.

looking forward to the solution.

New member

Posts

Joined
Mon Nov 09, 2009 4:04 pm

Post by billyggla » Mon Nov 08, 2010 7:52 pm

Ok got it working..

in /catalog/view/theme/default/template/product/product.tpl

find

Code: Select all

<input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
replace with

Code: Select all

<?php 
$min = $product_info['minimum'];
if ($min == 5) {
    echo "<select name='quantity'>
<option value='5'>5</option>
<option value='10'>10</option>
<option value='15'>15</option>
<option value='20'>20</option>
</select>";
} elseif ($min == '12') { 
echo "<select name='quantity'>
<option value='12'>12</option>
<option value='24'>24</option>
<option value='36'>36</option>
</select>";
} else {
echo "<input type='text' name='quantity' size='3' value='1' />";
}
?>
let me know how yoou get on..

Active Member

Posts

Joined
Mon Sep 20, 2010 7:05 am

Post by stewiek » Mon Nov 08, 2010 9:01 pm

test and it works like a charm! thanks man.

appreciate it very much

New member

Posts

Joined
Mon Nov 09, 2009 4:04 pm

Post by billyggla » Mon Nov 08, 2010 9:49 pm

Glad I could help..

Active Member

Posts

Joined
Mon Sep 20, 2010 7:05 am

Post by stewiek » Fri Nov 12, 2010 4:37 pm

another problem.

found out that the customer can still change the value on checking out. i think its in
template/checkout/cart.php

Tried to look into the file, but the code is different from the earlier one. so don't think I can replace it.

any idea?

New member

Posts

Joined
Mon Nov 09, 2009 4:04 pm

Post by billyggla » Fri Nov 12, 2010 5:56 pm

this will stop them being able to change quantity in the cart..

in checkout/cart.tpl

find this.

Code: Select all

<td align="right" valign="top"><input type="text" name="quantity[<?php echo $product['key']; ?>]" value="<?php echo $product['quantity']; ?>" size="3" /></td>
change to this.

Code: Select all

<td align="right" valign="top"><input type="hidden" name="quantity[<?php echo $product['key']; ?>]" value="<?php echo $product['quantity']; ?>" size="3" /><?php echo $product['quantity']; ?></td>

Active Member

Posts

Joined
Mon Sep 20, 2010 7:05 am

Post by stewiek » Fri Nov 12, 2010 9:40 pm

thanks. that will do.

New member

Posts

Joined
Mon Nov 09, 2009 4:04 pm

Post by sharku » Sun Apr 03, 2011 7:51 am

i got a more clear way to do this :
u just have to edit $xmax to set how many times the price will be multiplyed

cheers !

Code: Select all

<select name="quantity">
<?php 
$tempmin = $minimum;
$xmax = 20;
$x = 1;
echo '<option value="'.$minimum.'">'.$minimum.'</option>';
while($x <= $xmax){
$qstep = $minimum + $tempmin;
$x++;
echo '<option value="'.$qstep.'">'.$qstep.'</option>';
$tempmin = $minimum + $tempmin; } 
?>
</select>

Newbie

Posts

Joined
Tue Oct 26, 2010 10:22 am

Post by hydrowire » Wed Apr 13, 2011 10:14 pm

I had recently implemented this feature as an extension that you can download for free.

Download link: http://www.opencart.com/index.php?route ... on_id=1881

It does exactly what you want, with an added admin support for managing your quantity set values without any coding from your side.

More info: http://forum.opencart.com/viewtopic.php?f=119&t=30320

Developing Quality OpenCart Extensions since 2011.
View my extensions


User avatar
Active Member

Posts

Joined
Wed Jan 26, 2011 5:41 pm


Post by cdpritchard » Tue Jul 01, 2014 11:40 pm

@billyggla I like your solution for the dropdown. However, when I add it to my product.tpl page, I get this error:

Code: Select all

Undefined variable: product_info in /home/cygnetadmin/cygnetdisplays.com/vqmod/vqcache/vq2-catalog_view_theme_cygnet_template_product_product.tpl on line 265
Any idea how I can fix this?

Do I just need to delete the VQ Mode cache files?

User avatar
Newbie

Posts

Joined
Thu Jun 12, 2014 3:01 am

Post by suchismita » Wed Apr 01, 2015 11:47 pm

I am using opencart 1.5.5.1
I want quantity dropdown in product page, cart page and in category page also. Can you please help me?

Newbie

Posts

Joined
Wed Apr 01, 2015 11:43 pm
Who is online

Users browsing this forum: No registered users and 13 guests