Zozo Zozo
Zozo Zozo

Reputation: 151

How get cart content ? (prestashop)

I'd like get cart content on prestashop os-commerce. How can do it ?

Upvotes: 3

Views: 13523

Answers (5)

ButcherFromHell
ButcherFromHell

Reputation: 165

in .tpl file you can use cart object advantage and loop through products:

{foreach from=$cart->getProducts() item=product}
    {$product.name}
{/foreach}

Upvotes: 0

David S. P.
David S. P.

Reputation: 31

If you are using a hook on Shopping Cart page you can use:

$products = $params['products'];

Upvotes: 0

SagarPPanchal
SagarPPanchal

Reputation: 10121

Simply use

Context::getContext()->cart

refer this link https://www.prestashop.com/forums/topic/440516-how-to-get-all-product-ids-in-current-cart/

Upvotes: 2

Arslan Tabassum
Arslan Tabassum

Reputation: 940

It's Working: Enjoy

in module hook you can use this:

$products = $params['cart']->getProducts(true);

Upvotes: 0

Brice
Brice

Reputation: 1026

You should take a look at the Cart class, located in classes/Cart.php. There's a method called getProducts().

/**  
 * Return cart products  
 *  
 * @result array Products  
 */  
 public function getProducts($refresh = false, $id_product = false)  
 {  
   // code...  
 } 

Hope this helps,

Br,

Upvotes: 4

Related Questions