更新时间:2023-11-30 13:46:34
您可以像这样在购物车中获取商品:
You can get the items in the cart like this:
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
然后遍历所有项目,看看哪个ID最大.
Then loop through the items and see which one has the biggest id.
$max = 0;
$lastItem = null;
foreach ($items as $item){
if ($item->getId() > $max) {
$max = $item->getId();
$lastItem = $item;
}
}
if ($lastItem){
//do something with $lastItem
}