【发布时间】:2016-01-15 10:36:04
【问题描述】:
我收到一个错误:
致命错误:在非对象上调用成员函数 getProducts() 在 /var/www/vhosts/designsense.net.au/gypsy/public_html/catalog/controller/module/cart.php 第 23 行
这是我正在使用的代码。
class ControllerModuleCart extends Controller {
protected function index() {
$this->language->load('module/cart');
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_subtotal'] = $this->language->get('text_subtotal');
$this->data['text_empty'] = $this->language->get('text_empty');
$this->data['text_remove'] = $this->language->get('text_remove');
$this->data['text_confirm'] = $this->language->get('text_confirm');
$this->data['text_cart'] = $this->language->get('text_cart');
$this->data['text_checkout'] = $this->language->get('text_checkout');
$this->data['button_checkout'] = $this->language->get('button_checkout');
$this->data['button_remove'] = $this->language->get('button_remove');
$this->data['text_cart'] = $this->language->get('text_cart');
$this->data['cart'] = $this->url->link('checkout/cart');
$this->data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL');
// Get Cart Products
$this->data['products'] = array();
foreach ($this->cart->getProducts() as $result) {
$option_data = array();
foreach ($result['option'] as $option) {
$option_data[] = array(
'name' => $option['name'],
'value' => (strlen($option['option_value']) > 20 ? substr($option['option_value'], 0, 20) . '..' : $option['option_value'])
);
}
关于可能导致此问题的任何建议?
【问题讨论】:
-
这有关系吗? $this->data['cart'] = $this->url->link('checkout/cart'); ....... $this->cart->getProducts()
-
$this->cart 定义了吗?
-
@SpongePablo 我如何检查它是否是?代码不是我写的,所以不太清楚。
-
框架??代码点火器?
-
@mongjong 是这个 $this->data['cart'] = $this->url->link('checkout/cart');定义它?