【发布时间】:2013-02-28 05:58:52
【问题描述】:
我有一个产品的产品 ID。我想从购物车中获取该产品的数量,如果它已经在购物车中(如果它存在于已登录的用户那里)。
如果用户(注册)用户将产品添加到购物车离开站点。然后在某个时间他登录回站点并将相同的产品添加到购物车。此时我想检查是否有相同的产品购物车和产品的数量是多少?
$cart_m = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart_m->getAllItems() as $item)
{
$cart_productId = $item->getProduct()->getId();
$productPrice = $item->getProduct()->getPrice();
$productQuantity = $item->getProduct()->getQty();//I want to get specific product quantity,If I have product ID
}
【问题讨论】:
-
if($cart_productId == $theIdIwant) $theQtyIWant = $productQuantity;
标签: magento