Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Fetch Cart Content

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 08-09-2015, 04:47 AM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

Senior Member
  
Join Date: Jul 2015
Location: Dubai
Posts: 148
 

Default 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.
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
Reply With Quote
  #2  
Old 08-09-2015, 11:49 PM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

Senior Member
  
Join Date: Jul 2015
Location: Dubai
Posts: 148
 

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

}
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
Reply With Quote
  #3  
Old 08-17-2015, 01:30 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote

The following user thanks qualiteam for this useful post:
aneel13 (08-17-2015)
  #4  
Old 08-17-2015, 08:34 PM
  aneel13's Avatar 
aneel13 aneel13 is offline
 

Senior Member
  
Join Date: Jul 2015
Location: Dubai
Posts: 148
 

Default Re: Fetch Cart Content

Thanks!
__________________
Regards,
Aneel Sarwar
X-Cart version: 5.2.10
Windows: 7
Modules: Free version modules
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:01 PM.

   

 
X-Cart forums © 2001-2020