Page 1 of 2
[MOD] Menu for quantity discount prices
Posted: Sun Jan 31, 2010 8:04 pm
by OCyvon2
Hi,
I make a little change to the add to cart option.
If you wish to use multiple quantity and discount prices for a product in the option boxes you can download my contibution here:
http://www.opencart.com/index.php?route ... ion_id=411
Enjoy.
Re: Menu for quantity discount prices
Posted: Mon Feb 01, 2010 11:07 pm
by twiggy
Really nice looking mod, not tried it yet. What version is this for?
Re: Menu for quantity discount prices
Posted: Wed Feb 03, 2010 7:13 am
by OCyvon2
This is tested for 1.3.4 and works fine, but it will work also in 1.4.0 because its a minor change in the code of one file.
Re: [MOD] Menu for quantity discount prices
Posted: Thu Jul 22, 2010 7:05 am
by scanreg
Is this available?
Thanks
Re: [MOD] Menu for quantity discount prices
Posted: Thu Jul 22, 2010 2:09 pm
by OCyvon2
Re: [MOD] Menu for quantity discount prices
Posted: Thu Jul 22, 2010 7:26 pm
by f1nutter
I have a site that sells several different products in various case sizes but we list all the prices by individual unit price.
Now I know that there is a Minimum Quantity option under the product data which would make sure that a customer could only order the mimimum quantity but does mean for example if I set minimum quantity to 12 then a customer could still order 18 units (a case and a half).
I have managed to change the qty box on the products page to read only meaning someone can't overtype the qty but can only order 1 case at a time, but if you require 2 cases you have to click add to cart twice and also means if someone views their cart they can once again start ordering part cases.
Any advise would be very welcome and congratulations on producing such a professional and easy to use cart system.
Sorry forgot to mention am using 1.4.8b
Re: [MOD] Menu for quantity discount prices
Posted: Thu Jul 22, 2010 8:09 pm
by OCyvon2
maybe its better to use the discount option
You set the minimum order to 12 (price 12.000) and the discount to:
e.g.
quantity = 16, price = 10.000
quantity = 18, price = 9.000
quantity = 24, price = 8.000
Re: [MOD] Menu for quantity discount prices
Posted: Thu Jul 22, 2010 9:14 pm
by f1nutter
Had thought of this but we don't offer discounts for ordering more than 1 case and also this wouldn't solve the problem of being able to order part cases when viewing your cart.
I have used a few different carts before finding opencart (wish I had found this open first and saved myself hours of work) and I do remember changing oscommerce so that you could set quantity groups. Was just wondering if open cart has this anywhere???
Re: [MOD] Menu for quantity discount prices
Posted: Thu Jul 22, 2010 9:26 pm
by OCyvon2
Mmm... I don't have the time to look into that right now.
But maybe you can ask Qphoria (he is one of the experts).
Re: [MOD] Menu for quantity discount prices
Posted: Thu Jul 22, 2010 9:42 pm
by f1nutter
I will search again as wouldn't want to bother Qphoria until I'm certain it's not already answered else where
Thanks anyway OCyvon2
Re: [MOD] Menu for quantity discount prices
Posted: Thu Jul 22, 2010 9:48 pm
by OCyvon2
If you find your answer somewhere..... please post it here

Re: [MOD] Menu for quantity discount prices
Posted: Thu Jul 22, 2010 10:12 pm
by Qphoria
So if I understand correctly, you want to be able to a set quantities
12, 24, 36, 48
But not:
18, 26, 31 etc
correct?
Try this. (1.4.x only)
1. Set your minimum qty to 12
2. EDIT: system/library/cart.php
3. FIND:
Code: Select all
public function setMinQty() {
foreach ($this->getProducts() as $product) {
if ($product['quantity'] < $product['minimum']) {
$this->session->data['cart'][$product['key']] = $product['minimum'];
}
}
}
4. REPLACE WITH:
Code: Select all
public function setMinQty() {
foreach ($this->getProducts() as $product) {
if ($product['quantity'] < $product['minimum']) {
$this->session->data['cart'][$product['key']] = $product['minimum'];
} else {
$this->session->data['cart'][$product['key']] = ceil($product['quantity'] / $product['minimum']) * $product['minimum'];
}
}
}
(1.5.x)
1. EDIT: catalog/controller/checkout/cart.php
2. FIND (THE FIRST INSTANCE ONLY!):
Code: Select all
unset($this->session->data['shipping_methods']);
3. BEFORE, ADD:
Code: Select all
foreach($this->request->post['quantity'] as $product_id => $qty) {
foreach($this->cart->getProducts() as $product) {
if ($product['product_id'] == $product_id) {
$quantity = ceil($product['quantity'] / $product['minimum']) * $product['minimum'];
$this->cart->update($product_id, $quantity);
}
}
}
4. FIND:
Code: Select all
$this->cart->add($this->request->post['product_id'], $quantity, $option);
5. AFTER, ADD:
Code: Select all
foreach($this->cart->getProducts() as $product) {
if ($product['product_id'] == $this->request->post['product_id']) {
$quantity = ceil($product['quantity'] / $product['minimum']) * $product['minimum'];
$this->cart->update($this->request->post['product_id'], $quantity);
}
}
This should always increase the cart qty to the next set qty
Examples:
If you add 11, it will force 12
if you add 13, it will force 24
if you add 25, it will force 36
Re: [MOD] Menu for quantity discount prices
Posted: Thu Jul 22, 2010 10:22 pm
by OCyvon2
Even if it is not what f1nutter is looking for .... its very usefull.
Thanks Q
Re: [MOD] Menu for quantity discount prices
Posted: Thu Jul 22, 2010 10:36 pm
by f1nutter
Q
Did your very simple change and it's exactly what I needed.
Thank you so much
Re: [MOD] Menu for quantity discount prices
Posted: Tue Oct 12, 2010 4:18 am
by chapter5
just what I've been looking for! cheers!!
Re: [MOD] Menu for quantity discount prices
Posted: Sat Jan 01, 2011 9:44 pm
by nosecret
Can you help me, how to setting discount 50% off for minimal buy 3 products?
Re: [MOD] Menu for quantity discount prices
Posted: Fri Jan 14, 2011 4:40 pm
by merchboer
I edited my product.tpl in catalog/view/theme/YOURTHEME/template/product and changed this:
Code: Select all
<input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
to this:
Code: Select all
<?php if ($discounts) { ?>
<select name="quantity">
<?php foreach ($discounts as $discount) { ?>
<option value="<?php echo $discount['quantity']; ?>"><?php echo $discount['quantity']; ?></option>
<?php } ?>
</select>
<?php } else { ?>
<input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
<?php } ?>
so it automatically provides a dropdown menu on quantity discounts, which only gives the option to order in the quantities specified in the discount tab.
Though my shop is still in the works (not satisfied with what I got right now; want the price fields per piece to either display 3 decimals (only there), or maybe I'll mod the product.tpl another way) you can view the results here:
http://www.buttonsmaken.nl/onderdelen-o ... onderdelen.
You might notice I also added a "total" field to the quantity discount table.
Re: [MOD] Menu for quantity discount prices
Posted: Fri Jan 14, 2011 8:26 pm
by merchboer
hehe, so, already modded some more to get what I want. In case someone is interested (I did some frontend-output mods, in the backend the quantities are per 250 pcs, so 500 pcs output on frontend is quantity 2(*250) in the backend) I'm happy to post them.
Re: [MOD] Menu for quantity discount prices
Posted: Tue Feb 08, 2011 12:17 am
by ocnewby
public function setMinQty() {
foreach ($this->getProducts() as $product) {
if ($product['quantity'] < $product['minimum']) {
$this->session->data['cart'][$product['key']] = $product['minimum'];
} else {
$this->session->data['cart'][$product['key']] = ceil($product['quantity'] / $product['minimum']) * $product['minimum'];
}
}
}
This is great if you want to automatically give the next order size up, but customers may not like it if they order 13 and the system selects 24 if that is the case price.
to correct this replace the
ceil command with
floor and the app will round down.
That is:
if the minimum is 12 in a case, and they order 12 they will get 1 case
If they order 11 they will get 12 which is the minimum order.
if they order any number higher than 12 the system will select the next lower case size.
I don't know what i'm doing, but its fun anyway.
Re: [MOD] Menu for quantity discount prices
Posted: Fri Apr 08, 2011 6:13 pm
by jaconoarbenz
merchboer wrote:hehe, so, already modded some more to get what I want. In case someone is interested (I did some frontend-output mods, in the backend the quantities are per 250 pcs, so 500 pcs output on frontend is quantity 2(*250) in the backend) I'm happy to post them.
Yes please post. i really need this aswell.