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.
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]);
Code: Select all
$options = explode('|', $array[1]);
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;
}
}
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;
}
}
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();
}
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();
}
Code: Select all
$key = $product_id . ':' . implode('.', $options);
Code: Select all
$key = $product_id . ':' . implode('|', $options);
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
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.
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']
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 ;
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?
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?
Who is online
Users browsing this forum: No registered users and 32 guests