Поле выбора количества товара
И так делаем фиксированное значение выбора количества товара на странице продукта. Для этого нам понадобиться создать папки Ваша тема/woocommerce/global и создать в ней файл quantity-input.php
в него помещаем код
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<?php /** * Product quantity inputs * * @author WooThemes * @package WooCommerce/Templates * @version 2.1.0 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly global $product; $defaults = array( '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 ), ); if ( ! empty( $defaults['min_value'] ) ) $min = $defaults['min_value']; else $min = 1; if ( ! empty( $defaults['max_value'] ) ) $max = $defaults['max_value']; else $max = 12; if ( ! empty( $defaults['step'] ) ) $step = $defaults['step']; else $step = 2; ?> <div class="quantity_select"> <select name="<?php echo esc_attr( $input_name ); ?>" title="<?php _ex( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" class="qty"> <?php for ( $count = $min; $count <= $max; $count = $count+$step ) { if ( $count == $input_value ) $selected = ' selected'; else $selected = ''; echo '<option value="' . $count . '"' . $selected . '>' . $count . '</option>'; } ?> </select> </div> |
Сохраняем и вот что нас должно получиться
Оставить комментарий