Fetch Cart Content
I want to fetch the cart contents on the checkout page. How to do that? Also after that I would need to get details on each of the cart products e.g. name, description, sku etc.
|
Re: Fetch Cart Content
I was able to fetch the information using the following piece of code:
foreach($this->getCart()->getItems() as $item){ $listItems[$count] = array( "ItemId"=> $item->getSku(), "ItemDescription"=>$item->getName(), "ItemQuantity"=>$item->getAmount(), "ItemPrice"=>$item->getItemPrice(), "ItemTotalAmount"=>$item->calculateTotal(), "ItemImageURL"=>$item->getImageURL(), ); $orderTotalAmount += $item->calculateTotal(); $count++; } |
Re: Fetch Cart Content
I believe you don't need the $count variable as "$listItems[] = array(...)" will work too.
Also, it is a bad idea of doing this: "$orderTotalAmount += $item->calculateTotal();". You should use "$order->getTotal()" and "$order->getSubtotal()" methods instead. |
Re: Fetch Cart Content
Thanks!
|
All times are GMT -8. The time now is 11:01 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.