WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Fractions in products quantity (7 posts)

  1. anserran
    Member
    Posted 1 year ago #

    Hi there!

    I'm using your awesome plugin to develop a shop. Some of the products are sold by weight (kg), i.e., some costumer can add to his cart 0.5 kg of meat, for example.

    I've seen this is currently not possible in your plugin, since the quantity is always rounded before the product is added to the cart, using the function "absint" (in function woocommerce_update_cart_action() ). Is there any way that I missed to accomplish this without changing the plugin code?

    Thanks!

    http://wordpress.org/extend/plugins/woocommerce/

  2. royho
    Member
    Posted 1 year ago #

    Depending on how many different weights you need, one way around this would be to create variations.

  3. anserran
    Member
    Posted 1 year ago #

    Well, that's the thing. I really need all of them. Even if I stick only with half unit (0.5kg, 1kg, 1.5kg, 2.0kg...) I'd still have an undetermined number of variations, since clients can ask for any quantity (as in the physical shop)

  4. royho
    Member
    Posted 1 year ago #

    Yeah if you have alot of different weights, this solution would not be feasible...

  5. goozo
    Member
    Posted 1 year ago #

    @anserran did you end up solving this fractions issue in woocommerce?

    I have the same problem: I need to be able to do any fraction i.e. 1.2 or 3.4 etc..

  6. anserran
    Member
    Posted 1 year ago #

    Yeah, in some commit they substituted the absint(quantity) code in some places -which was the problem for me- for abs(quantity) allowing floating point values for quantities. That solved my problem. However, if I remember right, I think I had to remove some woocommerce hook or filter that still was transforming quantities to integers (some cleaning function, probably).

  7. ggoscarl
    Member
    Posted 1 year ago #

    The filter that you must remove is
    add_filter( 'woocommerce_stock_amount', 'intval' );
    and it's located in woocommerce-core-functions.php

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.