X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Fetch Cart Content (https://forum.x-cart.com/showthread.php?t=72552)

aneel13 08-09-2015 04:47 AM

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.

aneel13 08-09-2015 11:49 PM

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++;

}

qualiteam 08-17-2015 01:30 AM

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.

aneel13 08-17-2015 08:34 PM

Re: Fetch Cart Content
 
Thanks!


All times are GMT -8. The time now is 07:18 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.