Page 1 of 1
Decimal Quantity 1.4.9
Posted: Thu Sep 23, 2010 4:46 pm
by ht09
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.
Re: Decimal Quantity 1.4.9
Posted: Thu Sep 23, 2010 10:15 pm
by Qphoria
Try this:
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
Re: Decimal Quantity 1.4.9
Posted: Fri Mar 04, 2011 2:12 am
by josefto
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.
Re: Decimal Quantity 1.4.9
Posted: Mon Jan 02, 2012 5:24 pm
by jimaras
Hi
I need decimal quantity for 1.5.1.3
Can anyone help me?
Re: Decimal Quantity 1.4.9
Posted: Sat Feb 04, 2012 5:46 pm
by jarmil@resler.cz
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:
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
Re: Decimal Quantity v1.5.1.3.1
Posted: Sun Feb 19, 2012 12:13 am
by greeg
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?
Re: Decimal Quantity 1.4.9
Posted: Fri May 25, 2012 12:51 am
by gkapoor
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?
Re: Decimal Quantity 1.4.9
Posted: Sun Jul 15, 2012 2:11 am
by jorgg
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
Re: Decimal Quantity 1.4.9
Posted: Mon Apr 01, 2013 11:49 pm
by Horby
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?
Re: Decimal Quantity 2.0
Posted: Thu Dec 17, 2015 1:51 pm
by sathyasankar
How to do the same for 2.0