how to update downloadable product quantity in shopping cart in magento thuough php
$_product = Mage::getModel("catalog/product")->load($p_id);
$quote = Mage::getSingleton('checkout/session')->getQuote();
$item = $quote->getItemByProduct($_product);
$quote->updateItem($item->getId(), array( 'qty' => $p_qty)); getCart()->save();
Amit Dwivedi
1,57020 silver badges38 bronze badges
-
Is this a question ?Prateek– Prateek2015年12月22日 14:43:50 +00:00Commented Dec 22, 2015 at 14:43
-
yes, i m unable to increase or decrease the quantity of product in shopping cart item in magento 1.8Dhammapal Janbandhu– Dhammapal Janbandhu2015年12月23日 05:14:58 +00:00Commented Dec 23, 2015 at 5:14
1 Answer 1
Try this:
$quoteId = 1251;
$productItem['qty'] = 2;
$productId = 17;
$product = Mage::getModel("catalog/product")->load($productId);
$quote = Mage::getModel("sales/quote")->load($quoteId);
$quoteItem = $quote->getItemByProduct($product);
if ($productItem['qty'] > 0) {
$quoteItem->setQty($productItem['qty']);
}
try {
$quote->collectTotals()->save();
} catch (Exception $e) {
echo $e->getMessage();
}
answered Dec 23, 2015 at 6:04
Abdul
9,7291 gold badge22 silver badges44 bronze badges
-
not work plz update codes. $quoteItem = $quote->getItemByProduct($product); after that line exception occcur in phpDhammapal Janbandhu– Dhammapal Janbandhu2015年12月23日 06:28:24 +00:00Commented Dec 23, 2015 at 6:28
-
-
according to customer login, i have to change product quantity in cart but not success . Is there having any update method for update quantity and my product has a downladable product which are E-book and Print-book type contains linkDhammapal Janbandhu– Dhammapal Janbandhu2015年12月23日 08:14:27 +00:00Commented Dec 23, 2015 at 8:14
-
$quoteItem->setQty($productItem['qty']); <-- errorDhammapal Janbandhu– Dhammapal Janbandhu2015年12月23日 08:49:37 +00:00Commented Dec 23, 2015 at 8:49
default