• '.apply_filters('etheme_theme_label', 'XStore').''; ?>
  • '_et_quantity_type', 'label' => __( 'Type', 'xstore' ), 'options' => [ '' => __( 'Inherit', 'xstore' ), 'input' => __( 'Input', 'xstore' ), 'select' => __( 'Select', 'xstore' ), ], 'custom_attributes' => array('data-theme_mod-value' => get_theme_mod('shop_quantity_type', 'input')) ] ); woocommerce_wp_textarea_input( [ 'id' => '_et_quantity_ranges', 'label' => __( 'Range values', 'xstore' ), 'cols' => 50, 'rows' => 5, 'style' => 'height: 100px;', 'placeholder' => get_theme_mod('shop_quantity_select_ranges', '1-10'), 'desc_tip' => 'true', 'description' => __( 'This value will be used for select type ranged. Enter each value in one line and can use the range e.g "1-5".', 'xstore' ), ] ); ?>

    get_ID(); $quantity_type = get_post_meta($product_id, '_et_quantity_type', true); if ( empty($quantity_type) ) $quantity_type = get_theme_mod('shop_quantity_type', 'input'); $args['quantity_type'] = $quantity_type; if ( $quantity_type == 'select' ) { $quantity_range_values = get_post_meta($product_id, '_et_quantity_ranges', true); if ( empty($quantity_range_values) ) $quantity_range_values = get_theme_mod('shop_quantity_select_ranges', '1-5'); $quantity_range_values = apply_filters('etheme_quantity_ranges', $quantity_range_values, $args, $_product); $quantity_ranges = explode( "\n", str_replace( "\r", "", $quantity_range_values ) ); $quantity_range_options = []; if ( empty( $quantity_range_values ) ) { $quantity_range_options[] = 1; } else { foreach ( $quantity_ranges as $value ) { $value = trim($value); if ( is_numeric( $value ) ) { $quantity_range_options[] = intval( $value ); } elseif ( strpos( $value, '-' ) !== false ) { $range = explode( '-', $value ); if ( count( $range ) === 2 ) { $min = intval( $range[0] ); $max = intval( $range[1] ); $quantity_range_options = array_merge( $quantity_range_options, range( $min, $max ) ); } } } $quantity_range_options = array_unique( $quantity_range_options ); asort($quantity_range_options); $min_value = isset($args['min_value']) ? $args['min_value'] : 0; $max_value = isset($args['max_value']) ? $args['max_value'] : ''; foreach ( $quantity_range_options as $key => $number ) { if ( $min_value > $number || ( '' !== $max_value && $max_value > 0 && $max_value < $number ) ) { unset( $quantity_range_options[ $key ] ); } } } $args['quantity_values'] = $quantity_range_options; } return $args; }, 10, 2); /** * Filter template path * include quantity-select file only in case it is really needed */ add_filter('wc_get_template', function ($template, $template_name, $args) { if ( isset($args['quantity_type']) && $args['quantity_type'] == 'select' && basename( $template ) == 'quantity-input.php') { $template = ETHEME_CHILD . 'woocommerce/global/quantity-select.php'; if ( !file_exists($template) ) $template = ETHEME_BASE . 'woocommerce/global/quantity-select.php'; } return $template; }, 10, 3);