我正在尝试为我的woocommerce商店实施数量下拉,我发现下面的代码启用单个产品,但我不能让它适用于有变化的产品.
"cart[{$cart_item_key}][qty]", 'input_value' => $cart_item['quantity'], 'max_value' => $_product->backorders_allowed() ? '' : $_product->get_stock_quantity(), 'min_value' => '0' ), $_product, false ); */ function woocommerce_quantity_input($data) { global $product; $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; margin-right:10px;', $product ) ); if ( ! empty( $defaults['min_value'] ) ) $min = $defaults['min_value']; else $min = 1; if ( ! empty( $defaults['max_value'] ) ) $max = $defaults['max_value']; else $max = 20; if ( ! empty( $defaults['step'] ) ) $step = $defaults['step']; else $step = 1; $options = ''; for ( $count = $min; $count <= $max; $count = $count+$step ) { $selected = $count === $defaults['input_value'] ? ' selected' : ''; $options .= ''; } echo ''; } ?>
我追求的结果如下图所示
这可能与woocommerce?