Decimal Quantity 1.4.9
9 posts
• Page 1 of 1
Decimal Quantity 1.4.9
Does anyone know of a way to allow decimals in the quantity field? I need to sell fabric.
example: need to be able to enter 1.25 in quantity field and have the rest of the cart work.
Thanks in advance for any ideas on what files to edit to accomplish this.
example: need to be able to enter 1.25 in quantity field and have the rest of the cart work.
Thanks in advance for any ideas on what files to edit to accomplish this.
- ht09
- Posts: 2
- Joined: Sun Jun 20, 2010 9:24 pm
Re: Decimal Quantity 1.4.9
Try this:
1. EDIT: system/library/cart.php
2. FIND:
3. REPLACE WITH:
4. FIND:
5. REPLACE WITH:
6. FIND:
7. REPLACE WITH:
8. FIND:
9. REPLACE WITH:
10. Execute the following in your database using phpmyadmin:
Now you should be able to use a decimal qty
1. EDIT: system/library/cart.php
2. FIND:
- Code: Select all
$options = explode('.', $array[1]);
3. REPLACE WITH:
- Code: Select all
$options = explode('|', $array[1]);
4. FIND:
- Code: Select all
if ((int)$qty && ((int)$qty > 0)) {
if (!isset($this->session->data['cart'][$key])) {
$this->session->data['cart'][$key] = (int)$qty;
} else {
$this->session->data['cart'][$key] += (int)$qty;
}
}
5. REPLACE WITH:
- Code: Select all
if ((float)$qty && ((float)$qty > 0)) {
if (!isset($this->session->data['cart'][$key])) {
$this->session->data['cart'][$key] = (float)$qty;
} else {
$this->session->data['cart'][$key] += (float)$qty;
}
}
6. FIND:
- Code: Select all
public function update($key, $qty) {
if ((int)$qty && ((int)$qty > 0)) {
$this->session->data['cart'][$key] = (int)$qty;
} else {
$this->remove($key);
}
$this->setMinQty();
}
7. REPLACE WITH:
- Code: Select all
public function update($key, $qty) {
if ((float)$qty && ((float)$qty > 0)) {
$this->session->data['cart'][$key] = (float)$qty;
} else {
$this->remove($key);
}
$this->setMinQty();
}
8. FIND:
- Code: Select all
$key = $product_id . ':' . implode('.', $options);
9. REPLACE WITH:
- Code: Select all
$key = $product_id . ':' . implode('|', $options);
10. Execute the following in your database using phpmyadmin:
- Code: Select all
ALTER TABLE `product` CHANGE `quantity` `quantity` DECIMAL( 6, 2 ) NOT NULL ;
ALTER TABLE `product` CHANGE `minimum` `minimum` DECIMAL( 6, 2 ) NOT NULL ;
Now you should be able to use a decimal qty

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18199
- Joined: Mon Jul 21, 2008 7:02 pm

Re: Decimal Quantity 1.4.9
Hi, i've done everything you say to change to decimal quantity, and it works perfectly but in the order received by the client, which I receive and the history of the customer and the customer's request within the admin does not appear in decimal how to fix this.
Thank you for you request.
Thank you for you request.
- josefto
- Posts: 1
- Joined: Thu Mar 03, 2011 6:06 pm
Re: Decimal Quantity 1.4.9
Hi
I need decimal quantity for 1.5.1.3
Can anyone help me?
I need decimal quantity for 1.5.1.3
Can anyone help me?
- jimaras
- Posts: 128
- Joined: Wed Sep 14, 2011 5:45 pm
Re: Decimal Quantity 1.4.9
This works for me on v1.5.1.3.1 (could have some issues on extensions/features i do not use, but i guess it's a good starting point).
First replace ALL occurences -> replacements in given PHP files:
and then execute following SQL (e.g. from within phpmyadmin):
Hope this helps somebody
First replace ALL occurences -> replacements in given PHP files:
- Code: Select all
system/library/cart.php
(int)$qty -> (float)$qty
admin/model/catalog/product.php
(int)$data['quantity'] -> (float)$data['quantity']
(int)$product_option_value['quantity'] -> (float)$product_option_value['quantity']
(int)$product_discount['quantity'] -> (float)$product_discount['quantity']
admin/model/sale/order.php
(int)$order_product['quantity'] -> (float)$order_product['quantity']
(int)($download['remaining'] * $product['quantity']
-> (float)($download['remaining'] * (float)$product['quantity']
(int)$return_product['quantity'] -> (float)$return_product['quantity']
(int)$product['quantity'] -> (float)$product['quantity']
catalog/model/checkout/order.php
(int)$product['quantity'] -> (float)$product['quantity']
(int)($download['remaining'] * $product['quantity']
-> (float)($download['remaining'] * (float)$product['quantity']
(int)$order_product['quantity'] -> (float)$order_product['quantity']
and then execute following SQL (e.g. from within phpmyadmin):
- Code: Select all
ALTER TABLE `product` CHANGE `quantity` `quantity` DECIMAL( 6, 2 ) NOT NULL ;
ALTER TABLE `product` CHANGE `minimum` `minimum` DECIMAL( 6, 2 ) NOT NULL ;
ALTER TABLE `order_product` CHANGE `quantity` `quantity` DECIMAL( 6, 2 ) NOT NULL ;
Hope this helps somebody
- jarmil@resler.cz
- Posts: 1
- Joined: Sat Feb 04, 2012 9:37 am
Re: Decimal Quantity v1.5.1.3.1
done and now sells at 1.250 .. 3200 kg at present as to change the script now in grams 0.250... 0.750 .. who knows help me advice?
- greeg
- Posts: 1
- Joined: Sat Feb 18, 2012 3:59 pm
Re: Decimal Quantity 1.4.9
I am wondering if this can be done using option instead of modifying the OC core. I am selling bulk food products, have created a base product price/lb and want to allow customer to specify the weight for e.g. 1.5, 2.75 etc. before adding to the cart.
There are several option types (select, checkbox, text) but none of them will work in this scenario. I only don't see an option type of number/fraction which will multiple the base unit price. Anybody knows how to achieve this using options?
There are several option types (select, checkbox, text) but none of them will work in this scenario. I only don't see an option type of number/fraction which will multiple the base unit price. Anybody knows how to achieve this using options?
- gkapoor
- Posts: 1
- Joined: Sun Jan 22, 2012 11:04 pm
Re: Decimal Quantity 1.4.9
Anibody knows the answer to last question?
I would like to use it on a food store. I can now tell 1.00 , but could I use 1.25?
Thank you
I would like to use it on a food store. I can now tell 1.00 , but could I use 1.25?
Thank you
- jorgg
- Posts: 49
- Joined: Wed Mar 02, 2011 8:21 pm
Re: Decimal Quantity 1.4.9
The same question
gkapoor wrote:I am wondering if this can be done using option instead of modifying the OC core. I am selling bulk food products, have created a base product price/lb and want to allow customer to specify the weight for e.g. 1.5, 2.75 etc. before adding to the cart.
There are several option types (select, checkbox, text) but none of them will work in this scenario. I only don't see an option type of number/fraction which will multiple the base unit price. Anybody knows how to achieve this using options?
- Horby
- Posts: 15
- Joined: Thu Mar 14, 2013 12:05 pm
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: AutoSuppliesDirect, dgraves, hep05, Topsecret, Yahoo [Bot] and 43 guests













