• Resolved commercecode

    (@commercecode)


    Hi, it works perfectly with an input field, but if I implement this code down below, where I’m changing the input to dropdown, it stops working, what’s the workaround. Thank you.

    function woocommerce_quantity_input($data = null) {
    global $product;
    if (!$data) {
    $defaults = array(
    ‘input_name’ => ‘quantity’,
    ‘input_value’ => ‘1’,
    ‘max_value’ => apply_filters( ‘woocommerce_quantity_input_max’, ”, $product ),
    ‘min_value’ => apply_filters( ‘woocommerce_quantity_input_min’, ”, $product ),
    ‘step’ => apply_filters( ‘woocommerce_quantity_input_step’, ‘1’, $product ),
    ‘style’ => apply_filters( ‘woocommerce_quantity_style’, ‘float:left;’, $product )
    );
    } else {
    $defaults = array(
    ‘input_name’ => $data[‘input_name’],
    ‘input_value’ => $data[‘input_value’],
    ‘max_value’ => apply_filters( ‘woocommerce_quantity_input_max’, ”, $product ),
    ‘min_value’ => apply_filters( ‘woocommerce_quantity_input_min’, ”, $product ),
    ‘step’ => apply_filters( ‘woocommerce_quantity_input_step’, ‘1’, $product ),
    ‘style’ => apply_filters( ‘woocommerce_quantity_style’, ‘float:left;’, $product )
    );
    }

    if ( ! empty( $defaults[‘min_value’] ) )
    $min = $defaults[‘min_value’];
    else $min = 1;
    if ( ! empty( $defaults[‘max_value’] ) )
    $max = $defaults[‘max_value’];
    else $max = 100;
    if ( ! empty( $defaults[‘step’] ) )
    $step = $defaults[‘step’];
    else $step = 1;
    $options = ”;
    //fix add to cart data to send on cart page
    if (!empty($defaults[‘input_name’])) {
    $name = esc_attr($defaults[‘input_name’]);
    } else {
    $name = ‘quantity’;
    }

    for ( $count = $min; $count <= $max; $count = $count+$step ) {
    $selected = $count === $defaults[‘input_value’] ? ‘ selected’ : ”;
    $options .= ‘<option value=”‘ . $count . ‘”‘.$selected.’>’ . $count . ‘</option>’;
    }

    echo ‘<div class=”quantity_select” style=”‘ . $defaults[‘style’] . ‘”><select name=”‘ . $name . ‘” title=”‘ . _x( ‘Qty’, ‘Product quantity input tooltip’, ‘woocommerce’ ) . ‘” class=”qty”>’ . $options . ‘</select></div>’;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author taisho

    (@taisho)

    Hello,

    thanks for feedback, I’ve just released 1.02 version which supports dropdown lists, under condition that they have ‘qty’ class, what is true for your code.

    Kind Regards

    Thread Starter commercecode

    (@commercecode)

    appreciate taisho!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Make it Work with Dropdown’ is closed to new replies.