Reputation: 151
I'd like get cart content on prestashop os-commerce. How can do it ?
Upvotes: 3
Views: 13523
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
Reputation: 31
If you are using a hook on Shopping Cart page you can use:
$products = $params['products'];
Upvotes: 0
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
Reputation: 940
It's Working: Enjoy
in module hook you can use this:
$products = $params['cart']->getProducts(true);
Upvotes: 0
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