Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
How to add a quantity box with default qty 1 next to “Add to cart” buttons? 
 
homerun
Jr. Member
 
Total Posts:  16
Joined:  2008-09-18
 

How to add a quantity box with default qty 1 next to “Add to cart” buttons?

 
Magento Community Magento Community
Magento Community
Magento Community
 
crius
Guru
 
Avatar
Total Posts:  623
Joined:  2007-10-16
Denmark
 

I assume you are talking about the category page since the product page already have the quantity box. You can open up the template file for the product page and find the form with the box and more or less copy it to the category page. The quantity box will display the product’s minimal buying quantity as default or nothing if it’s not set. You can edit the box in the template file to always display 1.

 
Magento Community Magento Community
Magento Community
Magento Community
 
AnshumaanBakshi
Member
 
Avatar
Total Posts:  33
Joined:  2008-11-14
Delhi, India
 

Above seems to be right solution for now.

As I am trying to find an option Magento admin which can resolve this issues, but unable to find it.

If anyone knows how to resolve this issue without codding in then please do reply.

anyways in case you are coding then a conditional if should be implemented for default value coming in.

AB

 
Magento Community Magento Community
Magento Community
Magento Community
 
zuno
Jr. Member
 
Avatar
Total Posts:  30
Joined:  2008-10-08
Redondo Beach, CA
 

It’s very odd. If you set the “Minimum Qty Allowed in Shopping Cart” to anything more than 1 it automatically fills the quantity box on the frontent. The odd part is why it doesn’t auto fill the quantity box with 1 if your minimum is set to 1.

You set this under Catalog -> Manage Products -> Product -> Inventory

I guess I will put a conditional statement in the template file to default to 1 for quantity. Seems like extra work that should be handled by core.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Strattas
Jr. Member
 
Avatar
Total Posts:  19
Joined:  2008-12-07
California
 

Locate:
\app\design\frontend\default\default\template\catalog\product\view

Change the file:
addtocart.phtml

Find and Replace:
<input name="qty" type="text" class="input-text qty” id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) ?>” /></span>

With:
<input name="qty" type="text" class="input-text qty” id="qty" maxlength="12" value="1" /></span>

Works like a charm!

 
Magento Community Magento Community
Magento Community
Magento Community
 
bradbnaz
Jr. Member
 
Total Posts:  5
Joined:  2009-02-06
 
Anders Rasmussen - 24 September 2008 07:43 AM

I assume you are talking about the category page since the product page already have the quantity box. You can open up the template file for the product page and find the form with the box and more or less copy it to the category page. The quantity box will display the product’s minimal buying quantity as default or nothing if it’s not set. You can edit the box in the template file to always display 1.

I was able to get the the qty box to display on the category page by doing what you recommened, Thank you!  But when I put in a quanity and hit the add to cart button, it only adds a quanity of 1 to “My Cart” reguardles of the quanity I entered.  Meaning if I put a qty of 10 it only will add 1.  How can I fix this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Appmerce
Guru
 
Avatar
Total Posts:  376
Joined:  2008-05-13
Amsterdam, The Netherlands
 
bradbnaz - 04 March 2009 08:47 AM

Anders Rasmussen - 24 September 2008 07:43 AM
I assume you are talking about the category page since the product page already have the quantity box. You can open up the template file for the product page and find the form with the box and more or less copy it to the category page. The quantity box will display the product’s minimal buying quantity as default or nothing if it’s not set. You can edit the box in the template file to always display 1.

I was able to get the the qty box to display on the category page by doing what you recommened, Thank you!  But when I put in a quanity and hit the add to cart button, it only adds a quanity of 1 to “My Cart” reguardles of the quanity I entered.  Meaning if I put a qty of 10 it only will add 1.  How can I fix this?

You can’t, there’s no form on the category pages.... So you cant add the input form element. Rasmussen’s idea was wrong.

The real solutions is here http://www.magentocommerce.com/boards/viewthread/29345/#t96552

 
Magento Community Magento Community
Magento Community
Magento Community
 
crius
Guru
 
Avatar
Total Posts:  623
Joined:  2007-10-16
Denmark
 

You can’t, there’s no form on the category pages.... So you cant add the input form element. Rasmussen’s idea was wrong.

The real solutions is here http://www.magentocommerce.com/boards/viewthread/29345/#t96552

What’s the difference between that and my suggestion? You’re right that there is no form on the category pages. That’s why I suggested copying the form from the product page.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Bruno Morejon
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2009-06-05
 
wbayne333 - 04 March 2009 06:46 AM

Locate:
\app\design\frontend\default\default\template\catalog\product\view

Change the file:
addtocart.phtml

Find and Replace:
<input name="qty" type="text" class="input-text qty” id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) ?>” /></span>

With:
<input name="qty" type="text" class="input-text qty” id="qty" maxlength="12" value="1" /></span>

Works like a charm!

Thanks, that’s what I was looking for.

 
Magento Community Magento Community
Magento Community
Magento Community
 
steffeiter
Jr. Member
 
Total Posts:  9
Joined:  2009-11-21
 

I have had this isue too on 1.3.2 - I actually just tried to print out the variable used in the code:
<?php echo $this->getMinimalQty($_product); ?>

but it prints nothing.  This seems to be a magento core issue. Although I am using the Modern theme…

any ideas what variable to actually use, rather than hard code a value to this field?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Quaeso
Guru
 
Avatar
Total Posts:  334
Joined:  2010-04-03
 

I have 1.4.1.1, but my default quantity is empty, what´s wrong?

 
Magento Community Magento Community
Magento Community
Magento Community
 
optick
Member
 
Avatar
Total Posts:  34
Joined:  2008-07-20
Brasov, Romania
 

Hy,

Do you check “Minimum Qty Allowed in Shopping Cart” in admin panel ?

If you have 1 there try to see what you get in app\design\frontend\<your_theme>\<your_theme>\template\catalog\product\view\addtocart.phtml for this function <?php echo $this->getMinimalQty($_product) ?>

 
Magento Community Magento Community
Magento Community
Magento Community
 
Quaeso
Guru
 
Avatar
Total Posts:  334
Joined:  2010-04-03
 

Oh… thank you very much for your fast answer,
but where in admin panel must I check the minimum Qty allowed in shopping Cart?? I don´t find it..

 
Magento Community Magento Community
Magento Community
Magento Community
 
Quaeso
Guru
 
Avatar
Total Posts:  334
Joined:  2010-04-03
 

Hi Thank you, I found it now… it´s work…

 
Magento Community Magento Community
Magento Community
Magento Community
 
netfoliage
Jr. Member
 
Total Posts:  1
Joined:  2008-12-02
New York
 

You need to set Minimum Qty Allowed in Shopping Cart to 1*.

1. Go to Admin Panel -> System -> Configuration -> Inventory-> Product Stock Options
2.  Click on Add Minimum Qty button (next to Minimum Qty Allowed inShopping Cart)
3. Choose Customer Group: ALL GROUPS*
4. Enter 1* for Minimum Qty
5. Save Config

* Use whatever you need

 
Magento Community Magento Community
Magento Community
Magento Community
 
LilAndy23
Jr. Member
 
Total Posts:  16
Joined:  2010-09-02
 
netfoliage - 12 November 2010 09:49 AM

You need to set Minimum Qty Allowed in Shopping Cart to 1*.

1. Go to Admin Panel -> System -> Configuration -> Inventory-> Product Stock Options
2.  Click on Add Minimum Qty button (next to Minimum Qty Allowed inShopping Cart)
3. Choose Customer Group: ALL GROUPS*
4. Enter 1* for Minimum Qty
5. Save Config

* Use whatever you need

When I try to “Save Config” using combination of only All Groups = 1, it does not save within admin; it’s as if nothing was entered once the page postsback.  When I “Save Config” using on General = 1, it does save.  The only way I got it to save, is by selecting all possible Customer Groups and setting to Qty 1… does anyone know why this is?

Thanks
-Andy

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2