quantity-input.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Product quantity inputs
  4. *
  5. * This template can be overridden by copying it to yourtheme/woocommerce/global/quantity-input.php.
  6. *
  7. * HOWEVER, on occasion WooCommerce will need to update template files and you
  8. * (the theme developer) will need to copy the new files to your theme to
  9. * maintain compatibility. We try to do this as little as possible, but it does
  10. * happen. When this occurs the version of the template file will be bumped and
  11. * the readme will list any important changes.
  12. *
  13. * @see https://docs.woocommerce.com/document/template-structure/
  14. * @package WooCommerce/Templates
  15. * @version 3.4.0
  16. */
  17. defined( 'ABSPATH' ) || exit;
  18. if ( $max_value && $min_value === $max_value ) {
  19. ?>
  20. <div class="quantity hidden">
  21. <input type="hidden" id="<?php echo esc_attr( $input_id ); ?>" class="qty" name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $min_value ); ?>" />
  22. </div>
  23. <?php
  24. } else {
  25. /* translators: %s: Quantity. */
  26. $labelledby = ! empty( $args['product_name'] ) ? sprintf( __( '%s quantity', 'woocommerce' ), strip_tags( $args['product_name'] ) ) : '';
  27. ?>
  28. <div class="quantity">
  29. <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></label>
  30. <input
  31. type="number"
  32. id="<?php echo esc_attr( $input_id ); ?>"
  33. class="input-text qty text"
  34. step="<?php echo esc_attr( $step ); ?>"
  35. min="<?php echo esc_attr( $min_value ); ?>"
  36. max="<?php echo esc_attr( 0 < $max_value ? $max_value : '' ); ?>"
  37. name="<?php echo esc_attr( $input_name ); ?>"
  38. value="<?php echo esc_attr( $input_value ); ?>"
  39. title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ); ?>"
  40. size="4"
  41. pattern="<?php echo esc_attr( $pattern ); ?>"
  42. inputmode="<?php echo esc_attr( $inputmode ); ?>"
  43. aria-labelledby="<?php echo esc_attr( $labelledby ); ?>" />
  44. </div>
  45. <?php
  46. }