• I found another post on these forums pertaining to my query but it was for the WP eCommerce plugin, not the WooCommerce plugin.

    http://wordpress.org/support/topic/wp-e-commerce-decimals-in-quantity?replies=2

    I would like to enable decimals in my product quantities. As per the other post I amended the database from “INT” to “DECIMAL” but I’m having trouble finding the other code I need to edit in the plugin files.

    On the other post SkunkHunt mentions the following code needs replacing but I can’t locate the equivalent code in the WooCommerce files, can anyone point me in the right direction?

    What you want do is change instances of (int)$_POST['quantity']; to (float)$_POST['quantity'];
    
    Also change instances of (int)$_POST['wpsc_quantity_update']; to (float)$_POST['wpsc_quantity_update'];
    
    as well as (int)$_POST['wpsc_quantity_update'][$_POST['product_id']]; to (float)$_POST['wpsc_quantity_update'][$_POST['product_id']];
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter nicolethompson8

    (@nicolethompson8)

    OK I have actually managed to pull this off to a certain extent, by finding some similar code to the post I linked above, I changed “int” to “float” in a few places in “woocommerce-functions.php”.

    This has worked, on single product pages my quantities are now in decimal form and I can type in whatever decimal I want then add it to my cart successfully. It even reflects the correct decimal quantities (and multiplied prices) when you navigate to the cart and continues to preserve the decimal quantity and correct price after you proceed to checkout….

    …. BUT, the minute you “update” the cart the decimal is lost and it returns to be a whole integer number (e.g. if my decimal was 6.9 then it returns 6 as the quantity).

    Any idea what I can now edit to preserve the decimals when the cart is updated, please?

    Hi, how did u go with this, did you have any more luck? I’d also really like to implement woocommerce but their lack of decimals is the only thing holding me back. I am also a PHP dev. so I’m keen to have a hack. I haven’t seen any of the code yet, is the update cart an ajax request? Is there a way to install a trial of woo commerce? Perhaps then I can have a hack too 🙂

    Just wondering if there was any further development on this?

    Need to solve this issue myself and its been driving me bonkers for a long, long time.

    Not Woocommerce but E-Commerce in my case, any help would be appreciated.

    Thanks,
    Martin

    After checking the code I can see that the cart update function converts the quantity value into a positive integer using absint

    Change

    // Clean the quantity input
    $quantity = absint( $cart_totals[$cart_item_key]['qty'] );

    to

    // DON'T Clean the quantity input
    $quantity = $cart_totals[$cart_item_key]['qty'] ;

    Should sort out the update issue.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WooCommerce’ is closed to new replies.