Use input of type "number" for quantity selection

Created on 19 October 2023, 9 months ago
Updated 25 October 2023, 8 months ago

Problem/Motivation

The form to quickly add a product to the cart, currently displays an input of type "text" for quantity selection. Using an input of type "number" seems to bee more suitable. Additionally most browsers display controls for inputy of type "number" to help the user setting the quantity.

✨ Feature request
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany sboetticher

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sboetticher
  • πŸ‡ͺπŸ‡ͺEstonia drugan

    The reason why it is a textfield is quantity might be integer as well as decimal type of a number too:

    1, 123, 0.1, 1.123, 1235.6789, etc ...
    

    So to implement a number field type here we also need to dynamically set #step property of the field based on its settings on an order item type. Which we don't know in advance before a customer has selected variation (type) in the list.

    To grasp the complexity of the task you can install commerce_xquantity β†’ module and try to play with different quantity number types. It is quite a legal case when some Drupal Commerce site sell its products measured by kilo+grams or liter+milliliters or any other similar unit.

    In my mind this game is not worth the candle. Much simpler would be to set a placeholder on the field giving possible value hint for a customer.

  • πŸ‡©πŸ‡ͺGermany sboetticher

    I understand and agree. My case is a simple one without decimal etc.
    Thanks for the explanation.

  • Status changed to Closed: works as designed 8 months ago
  • πŸ‡ͺπŸ‡ͺEstonia drugan
Production build 0.69.0 2024