woocommerce code help

Degen

Elite Member
Joined
Apr 9, 2016
Messages
2,604
Reaction score
2,899
Code:
function woocommerce_quantity_input($data = null) {
    global $product;
    $defaults = array(
        'input_name' => array_key_exists('input_name', $data) ? $data['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; margin-right:10px;', $product )
    );
    if ( ! empty( $defaults['min_value'] ) )
        $min = $defaults['min_value'];
    else $min = 1000;
    if ( ! empty( $defaults['max_value'] ) )
        $max = $defaults['max_value'];
    else $max = 10000;
    if ( ! empty( $defaults['step'] ) )
        $step = $defaults['step'];
    else $step = 1000;
    $options = '';

    for ( $count = $min; $count <= $max; $count = $count+$step ) {
        $selected = ($count === $data['input_value']) ? ' selected' : '';
        $options .= '<option value="' . $count . '"'.$selected.'>' . $count . ''; }

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

Ok so the code works but only the steps part doesn't .

It still takes steps of 1 while it is supposed to take steps of 1000. Anyone know why and how to fix it ?
 
Back
Top