Post by ht09 » Thu Sep 23, 2010 4:46 pm

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.

Newbie

Posts

Joined
Mon Jun 21, 2010 5:24 am

Post by Qphoria » Thu Sep 23, 2010 10:15 pm

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

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by josefto » Fri Mar 04, 2011 2:12 am

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.

Newbie

Posts

Joined
Fri Mar 04, 2011 2:06 am

Post by jimaras » Mon Jan 02, 2012 5:24 pm

Hi
I need decimal quantity for 1.5.1.3
Can anyone help me?

http://e-kreopoleio.com/


Active Member

Posts

Joined
Thu Sep 15, 2011 1:45 am

Post by jarmil@resler.cz » Sat Feb 04, 2012 5:46 pm

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


Posts

Joined
Sat Feb 04, 2012 5:37 pm

Post by greeg » Sun Feb 19, 2012 12:13 am

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?

Newbie

Posts

Joined
Sat Feb 18, 2012 11:59 pm

Post by gkapoor » Fri May 25, 2012 12:51 am

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?

Newbie

Posts

Joined
Mon Jan 23, 2012 7:04 am

Post by jorgg » Sun Jul 15, 2012 2:11 am

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

New member

Posts

Joined
Thu Mar 03, 2011 4:21 am

Post by Horby » Mon Apr 01, 2013 11:49 pm

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?

Newbie

Posts

Joined
Thu Mar 14, 2013 8:05 pm

Post by sathyasankar » Thu Dec 17, 2015 1:51 pm

How to do the same for 2.0

Newbie

Posts

Joined
Thu Nov 19, 2015 2:07 pm
Who is online

Users browsing this forum: Baidu [Spider] and 56 guests