Hi guys,
Thanks in advance. I am new to opencart and am currently developing a shopping cart in opencart and everything is going smoothly, but I'm stuck, please help.
I want to access the currently added basket items in the checkout.tpl file to create a request form, so I edited the /checkout.php controller and added these lines of code to access the product information that is currently in the basket:
//Product detail for Enquiry $product_data = array(); foreach ($this->cart->getProducts() as $product) { $option_data = array(); foreach ($product['option'] as $option) { if ($option['type'] != 'file') { $value = $option['option_value']; } else { $value = $this->encryption->decrypt($option['option_value']); } $option_data[] = array( 'product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'option_id' => $option['option_id'], 'option_value_id' => $option['option_value_id'], 'name' => $option['name'], 'value' => $value, 'type' => $option['type'] ); } $product_data[] = array( 'product_id' => $product['product_id'], 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'download' => $product['download'], 'quantity' => $product['quantity'], 'subtract' => $product['subtract'], 'price' => $product['price'], 'total' => $product['total'], 'tax' => $this->tax->getTax($product['price'], $product['tax_class_id']), 'reward' => $product['reward'] ); } $data['products'] = $product_data;
and then added a line to checout / checkout.tpl:
foreach ($products as $product) { echo 'yes am getting products details'; }
but still an error occurs: Undefined variable: products?
Am I doing it right? please correct me.
source share