WordPress.org

Support

Support » Plugins and Hacks » WooCommerce » [Resolved] [Plugin: WooCommerce – excelling eCommerce] Fractions in products quantity

[Resolved] [Plugin: WooCommerce – excelling eCommerce] Fractions in products quantity

  • 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/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author royho

    @royho

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

    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)

    Plugin Author royho

    @royho

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

    @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..

    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).

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] [Plugin: WooCommerce – excelling eCommerce] Fractions in products quantity’ is closed to new replies.
Skip to toolbar