WordPress.org

Support

Support » Plugins and Hacks » WooCommerce – Quantity (0.5 units) in products quantity

WooCommerce – Quantity (0.5 units) in products quantity

  • Hi there,

    I’m building an e-commerce store which sells meat, poultry and the like -so units of products usually are in weight rather than units.
    I’m trying to figure out how I can configure the ‘quantity’ selector to have increments of 0.5 rather than the default (=1).
    Another idea I had was to eliminate the ‘quantity’ selector all together and have the weight of the products referenced by variables (weight – 0.5kg,1.0kg,1.5kg etc) – that selection would display the ‘add to cart button’.
    I tried the code below but I had two issues:
    1. Although the initial and minimal values changed to 0.5 units, the increase/decrease is by 1 unit.
    2. The code affects only simple products and not variables as well, what would I need to do to have that affect variable products too?

    P.S
    I saw a similar post but I didn't understand how they achieved this
    http://wordpress.org/support/topic/plugin-woocommerce-excelling-ecommerce-fractions-in-products-quantity?replies=7
    
    Best Regards and thanks in advance
    Ofer
    ===================================Code Below======================

    add_action( ‘init’, ‘add_filter_to_overwrite_increment’ );

    function add_filter_to_overwrite_increment() {
    add_filter( ‘woocommerce_quantity_input_args’, ‘overwrite_woocommerce_quantity_input_args’, 10, 2 );
    }

    function overwrite_woocommerce_quantity_input_args( $args, $product ) {
    $args[‘input_value’] = 0.5; // Starting quantity value
    $args[‘max_value’] = 10; // Quantity can not go beyond this value
    $args[‘min_value’] = 0.5; // Quantity cannot go below this value
    $args[‘step’] = 0.5; // Value with which you want to increment or decrement
    return $args;
    }

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

Viewing 1 replies (of 1 total)
  • Hi,
    I am trying to achieve similar. We are using the plugin WP e-Commerce by GetShopped.org for a fabric commerce site where the customer needs to be able to choose any length of fabric (in metres or part there of).

Viewing 1 replies (of 1 total)
  • The topic ‘WooCommerce – Quantity (0.5 units) in products quantity’ is closed to new replies.