Set default "Quantity" dropdown select in product. Commerce Kickstart

Drupal Answers Asked by chefnelone on December 10, 2020

Using the Commerce Kickstart distribution I have a shop site listing products.
The product page shows a Quantity widget to allow the buyer to choose the product quantity to be added to the cart. (look my capture)

I need to change this widget to the standar select list html element. (look the capture)

Update: I found the library which generate this “spinner”, is located at: profiles/commerce_kickstart/libraries/jquery_ui_spinner I don’t see any module related to this. Maybe in theme?

enter image description here

One Answer

I know its already a year ago, but if someone bump in this question here's one of the solution, I don't know if there's a module that already existing changing the widget type of quantity in add to cart form but you can achieve this using hook_form_commerce_cart_add_to_cart_form_alter like this


function example_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state) {
  // Change widget type of quantity to select list
  $form['quantity'] = array(
    '#title' => t('Quantity'),
    '#type' => 'select',
    '#datatype' => 'integer', // <-- I added this one to fix Notice: Undefined index: #datatype in commerce_cart_add_to_cart_form_validate() when you click add to cart button
    '#options' => array(
      1 => '1',
      2 => '2',
      3 => '3',
      4 => '4',
      5 => '5'

Answered by iamroald on December 10, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP