Vote up!
Vote down!

Product display hidden quantity field


I would like to display the quantity input of the add to cart form.

I render the add to cart form like this:
$form_id = commerce_cart_add_to_cart_form_id(array($produit->product_id));
$line_item = commerce_product_line_item_new($produit);
$line_item->data['context']['product_ids'] = array($produit->product_id);
$form = drupal_get_form($form_id, $line_item);
print render($form);

in a node--display-product.tpl.php

Moreover, I have set the display of this content type:
Widget quantity: active
and check the first checkbox ("display a widget of type text...")

But I don't understand why the quantity input is hidden !

Thanks for your help,

Adrien Durmier
Asked by: Adrien Durmier
on December 3, 2015

2 Answers

Vote up!
Vote down!

It's OK I have forget to set "Combiner les éléments identiques : Activé"...

Adrien Durmier
Answer by: Adrien Durmier
Posted: Dec 11, 2015
Vote up!
Vote down!

Hi Adrien,

I got the same question. Could you please share your method to solve this?

I added the code into node--product-display.tpl.php, but the quantity doesn't show up on the browser.

$line_item2 = commerce_product_line_item_new($equivalent_product,1);
$line_item2->data['context']['product_ids'] = array($equivalent_product->product_id);

$form = drupal_get_form('commerce_cart_add_to_cart_form', $line_item2);
print render($form);

What do I need to do to make the quantity input form show up?


Answer by: jmu
Posted: May 26, 2016