cancel
Showing results for 
Search instead for 
Did you mean: 

Minimum Qty Allowed in Shopping Cart

Minimum Qty Allowed in Shopping Cart

Hello All,

 

I am using Magento version 1.9.2.0

 

I am trying to pull the 'Minimum Qty Allowed in Shopping Cart' into the cart page. Basically i want to add it directly under the Product name.

 

I have been able to pull in the Product ID and SKU using the following:

<?php
    $items = Mage::getModel('checkout/cart')->getQuote()->getAllItems();

    foreach($items as $item) {
        echo 'ID: '.$item->getProductId().'<br />';
        echo 'Sku: '.$item->getSku().'<br />';

        echo "<br />";
    }

but if i try use the following it just returns the label (Qty Per Case) and  (Qty Per Case2)

<?php
    $items = Mage::getModel('checkout/cart')->getQuote()->getAllItems();

    foreach($items as $item) {
		echo 'Qty Per Case: '.$item->getMinQty().'<br />';
		echo 'Qty Per Case 2: '.$item->getMinSaleQty().'<br />';

        echo "<br />";
    }

Please can someone point me in the right direction....this is rather frustrating

 

Thanks

Garth

 

4 REPLIES

Re: Minimum Qty Allowed in Shopping Cart

Try following way

$items = Mage::getModel('checkout/cart')->getQuote()->getAllItems();

foreach($items as $item) {
$product = $item->getProduct();
$stock = $product->getStockItem();
echo 'ID: '.$product->getId().'<br />';
echo 'Sku: '.$product->getSku().'<br />';
echo $stock->getMinSaleQty();
}
Sohel Rana
ZCE,MCD,MCD+,M2CAD

Re: Minimum Qty Allowed in Shopping Cart

Hi There,

 

That's perfect......thank you very much

 

G

Re: Minimum Qty Allowed in Shopping Cart

Sorry, one more question.

 

I can now get the Min Qty to show but i am struggling to place it where i want.

 

I am editing the checkout/cart.phtml file. I cant seem to find where to place the code to add the MinQty just below the product name, like this:

 

Product Name

Product One

MinQty

 

The name of the product is placed in a <td> which i assume is generated elsewhere....

 

Any ideas?


Garth

Re: Minimum Qty Allowed in Shopping Cart

Hello,

 

I managed to sort this out by adding the following code to the checkout/cart/item/default.phtml file

<?php
$items = Mage::getModel('checkout/cart')->getQuote()->getAllItems();

foreach($items as $item) {
    $product = $item->getProduct();
    $stock = $product->getStockItem();
    echo 'Qty Per Case: '.$stock->getMinSaleQty();
}
?>

But there is a small problem......if i add more than one item/product to the cart then it ads the qty for both items under each product...like this:

 

Product One

Qty: 6 Qty 12

 

Product Two

Qty: 6 Qty 12

 

Product One should only have 'Qty: 6' and Product Two should only have 'Qty: 12'

 

Does anyone have any idea what i am doing wrong?

 

Thanks

Garth