Post by OCyvon2 » Sun Jan 31, 2010 8:04 pm

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.

Attachments

change_quantity_into_menu.png

sample - change_quantity_into_menu.png (17.06 KiB) Viewed 14863 times

Last edited by i2Paq on Thu Oct 14, 2010 12:01 am, edited 1 time in total.
Reason: Topic moved

OpenCartstore
Gebruikersgids (admin handleiding)


User avatar
Active Member

Posts

Joined
Sun Jan 31, 2010 8:00 pm
Location - Zaandam, The Netherlands

Post by twiggy » Mon Feb 01, 2010 11:07 pm

Really nice looking mod, not tried it yet. What version is this for?

Active Member

Posts

Joined
Fri Aug 14, 2009 4:43 am


Post by OCyvon2 » Wed Feb 03, 2010 7:13 am

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.

OpenCartstore
Gebruikersgids (admin handleiding)


User avatar
Active Member

Posts

Joined
Sun Jan 31, 2010 8:00 pm
Location - Zaandam, The Netherlands

Post by scanreg » Thu Jul 22, 2010 7:05 am

Is this available?

Thanks

Active Member

Posts

Joined
Thu May 06, 2010 12:15 am

Post by OCyvon2 » Thu Jul 22, 2010 2:09 pm

quantity change

this is it.

OpenCartstore
Gebruikersgids (admin handleiding)


User avatar
Active Member

Posts

Joined
Sun Jan 31, 2010 8:00 pm
Location - Zaandam, The Netherlands

Post by f1nutter » Thu Jul 22, 2010 7:26 pm

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

Newbie

Posts

Joined
Wed Jul 14, 2010 4:53 pm

Post by OCyvon2 » Thu Jul 22, 2010 8:09 pm

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

OpenCartstore
Gebruikersgids (admin handleiding)


User avatar
Active Member

Posts

Joined
Sun Jan 31, 2010 8:00 pm
Location - Zaandam, The Netherlands

Post by f1nutter » Thu Jul 22, 2010 9:14 pm

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

Newbie

Posts

Joined
Wed Jul 14, 2010 4:53 pm

Post by OCyvon2 » Thu Jul 22, 2010 9:26 pm

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

OpenCartstore
Gebruikersgids (admin handleiding)


User avatar
Active Member

Posts

Joined
Sun Jan 31, 2010 8:00 pm
Location - Zaandam, The Netherlands

Post by f1nutter » Thu Jul 22, 2010 9:42 pm

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

Newbie

Posts

Joined
Wed Jul 14, 2010 4:53 pm

Post by OCyvon2 » Thu Jul 22, 2010 9:48 pm

If you find your answer somewhere..... please post it here ;D

OpenCartstore
Gebruikersgids (admin handleiding)


User avatar
Active Member

Posts

Joined
Sun Jan 31, 2010 8:00 pm
Location - Zaandam, The Netherlands

Post by Qphoria » Thu Jul 22, 2010 10:12 pm

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

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by OCyvon2 » Thu Jul 22, 2010 10:22 pm

Even if it is not what f1nutter is looking for .... its very usefull.

Thanks Q

OpenCartstore
Gebruikersgids (admin handleiding)


User avatar
Active Member

Posts

Joined
Sun Jan 31, 2010 8:00 pm
Location - Zaandam, The Netherlands

Post by f1nutter » Thu Jul 22, 2010 10:36 pm

Q

Did your very simple change and it's exactly what I needed.

Thank you so much

Newbie

Posts

Joined
Wed Jul 14, 2010 4:53 pm

Post by chapter5 » Tue Oct 12, 2010 4:18 am

just what I've been looking for! cheers!!

Newbie

Posts

Joined
Fri Jul 09, 2010 3:42 pm

Post by nosecret » Sat Jan 01, 2011 9:44 pm

Can you help me, how to setting discount 50% off for minimal buy 3 products?

Active Member

Posts

Joined
Tue Dec 28, 2010 12:28 pm

Post by merchboer » Fri Jan 14, 2011 4:40 pm

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.

I likez teh beerz & foodz.


User avatar
Active Member

Posts

Joined
Fri Jan 14, 2011 4:27 pm
Location - Netherlands

Post by merchboer » Fri Jan 14, 2011 8:26 pm

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.

I likez teh beerz & foodz.


User avatar
Active Member

Posts

Joined
Fri Jan 14, 2011 4:27 pm
Location - Netherlands

Post by ocnewby » Tue Feb 08, 2011 12:17 am

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. :drunk:

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.

Newbie

Posts

Joined
Sat Jan 22, 2011 2:37 pm

Post by jaconoarbenz » Fri Apr 08, 2011 6:13 pm

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.

Newbie

Posts

Joined
Fri Apr 08, 2011 8:34 am
Who is online

Users browsing this forum: No registered users and 21 guests