Answer the question
In order to leave comments, you need to log in
$items = $this->cart->getProducts() Returns an empty array. Why?
Good afternoon!
In the controller file /catalog/controller/checkout/success.php I need to get data about the product in the cart.
I write such code $items = $this->cart->getProducts();
As a result I receive an empty array. Tell me, please, why?
Answer the question
In order to leave comments, you need to log in
Hello. I'm not very familiar with opencart, but purely logically, judging by the fact that you are trying to get goods in the successful payment controller, you are unlikely to succeed, since in theory the basket should already be cleared.
Googling a little, I found such things as: $this->session->data['order_id']
- the last order of the user, as I understand it, from which we can do this:
$this->load->model('account/order');
$order_id = $this->session->data['order_id'];
$products = $this->model_account_order->getOrderProducts($order_id);
$this->cart->clear();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question