Reputation: 23151
How can I get cart information in open cart? I'm trying to get things like cart total in the tag.
I've tried $this->cart
(Undefined property: Loader::$cart
), and $registry->get('cart')
.
I'm editing catalog/view/theme/default/template/common/header.tpl
Upvotes: 2
Views: 6621
Reputation: 23151
Here's how I did it (so i don't forget next time!)
in the file catalog/controller/common/cart.php
Line 138
You can store the $data
variable in the $_SESSION:
$_SESSION['cart_data'] = $data;
Upvotes: 1
Reputation: 898
You can't load the library files in .tpl files in Opencart 2.X, You have to do this in controller & assign that variable in template file. eg
// Write something like that in controller
$data['cartData'] = $this->cart->getProducts();
You can access the cart products in .tpl file in $cartData
variable.
Upvotes: 5