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

$this->getMinimalQty($_product) always return empty string? 
 
zhlmmc
Member
 
Total Posts:  60
Joined:  2008-07-14
 

I found that $this->getMinimalQty($_product) always return empty string, so the Qty box in front end is always empty by default. Already filed bug http://www.magentocommerce.com/bug-tracking/issue?issue=5498

Is there any workaround for this issue?

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Manos Dilaverakis
Member
 
Total Posts:  49
Joined:  2009-02-25
 

What class is “$this”? Does it or any of the classes it extends have a “getMinimalQty” method? Does it extend Varien_Object? What exactly is “$_product”? We might be able to help if you post some more details like in which file this is as well as the rest of the code.

 
Magento Community Magento Community
Magento Community
Magento Community
 
zhlmmc
Member
 
Total Posts:  60
Joined:  2008-07-14
 

Hi Manos,

Here is the file that I modified and the Qty box will show “1” in the front end now.

File: /app/design/frontend/default/modern/template/catelog/product/view/addtocart.phtml

<?php $_product $this->getProduct() ?>

<?php 
if($_product->isSaleable()): ?>
    
<fieldset class="add-to-cart-box">
        <
legend><?php echo $this->__('Add Items to Cart'?></legend>
        
<?php if(!$_product->isGrouped()): ?>
        
<span class="qty-box"><label for="qty"><?php echo $this->__('Qty'?>:</label>
<!-- 
Custom Code Begin -->
<!--
        <
input name="qty" type="text" class="input-text qty" id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) ?>"/>
-->
        <
input name="qty" type="text" class="input-text qty" id="qty" maxlength="12" value="1"/>
<!-- 
Custom End Begin -->
        </
span>
        
<?php endif; ?>
        
<a href="#" onclick="productAddToCartForm.submit(); return false;"<?php if($_product->isGrouped()): ?> class="right"<?php endif;?>><img src="<?php echo $this->getSkinUrl('images/btn_add_to_cart.gif');?>" alt="<?php echo $this->__('Add to Cart') ?>" class="v-middle" style="margin:0 0 0 5px;" /></a>
    </
fieldset>
<?php endif; ?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Manos Dilaverakis
Member
 
Total Posts:  49
Joined:  2009-02-25
 

That’s odd… I just checked my eshop and it works fine (v1.2). Maybe you set the product minimum quantity setting in your admin panel for the wrong store/view?

 
Magento Community Magento Community
Magento Community
Magento Community
 
zhlmmc
Member
 
Total Posts:  60
Joined:  2008-07-14
 

I checked the product minimum quantity setting. It is “1”. Not sure what’s the problem.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jchgo
Jr. Member
 
Avatar
Total Posts:  2
Joined:  2008-12-01
 

"1” and “product minimum quantity” setting in admin (v1.3.2.1)

File: /app/design/frontend/default/default/template/catelog/product/view/addtocart.phtml

<?php $_product $this->getProduct() ?>

<?php 
if($_product->isSaleable()): ?>
    
<fieldset class="add-to-cart-box">
        <
legend><?php echo $this->__('Add Items to Cart'?></legend>
        
<?php if(!$_product->isGrouped()): ?>
        
<span class="qty-box"><label for="qty"><?php echo $this->__('Qty'?>:</label>
<!-- 
Custom Code Begin -->
<!--
        <
input name="qty" type="text" class="input-text qty" id="qty" maxlength="12" value="<?php //echo $this->getMinimalQty($_product) ?>"/>
-->
        <
input name="qty" type="text" class="input-text qty" id="qty" maxlength="12" value="<?php if ($this->getMinimalQty($_product)>1): ?> <?php echo $this->getMinimalQty($_product) ?> <?php else: ?> <?php echo $this->__('1') ?>  <?php endif; ?>"/>
<!-- 
Custom End Begin -->
        </
span>
        
<?php endif; ?>
        
<button type="button" class="form-button" onclick="productAddToCartForm.submit()"><span><?php echo $this->__('Add to Cart'?></span></button>
    </
fieldset>
<?php endif; ?>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top