Opencart 2在产品详细信息页面上显示客户变量

时间:2016-03-31 14:43:59

标签: php opencart2.x

我正在使用Opencart 2.1.0.2,并在客户mysql表中添加了一个新列。我需要在客户查看产品详细信息页面时显示客户mysql客户行的唯一值。但是我收到以下错误

注意:未定义的变量:第165行的public_html / catalog / view / theme / rgen-opencart / template / product / product.tpl中的mypaycheckschedule

以下是我的代码(我不确定我缺少什么)

文件:public_html / catalog / model / catalog / product.php

public function getProduct($product_id) {
            //see if user is logged in and if so get a custom variable to show on product detail page
            if($this->customer->isLogged()) 
              {
                  $queryb = $this->db->query("SELECT paycheckschedule FROM " . DB_PREFIX . "customer WHERE customer_id = '" . $this ->customer->getId() ."'");
                  if($queryb->row['paycheckschedule'] =='')
                    {
                       $queryb->row['paycheckschedule'] = 'none';
                    }
              }
               else
              {
                  $queryb->row['paycheckschedule'] = 'n/a';
              }

然后我在同一个文件中

        if ($query->num_rows) {
        return array(
            'product_id' => $query->row['product_id'],
            'mypaycheckschedule'  => $queryb->row['paycheckschedule'], 
            'name' => $query->row['name'],

然后在我的 的public_html /目录/控制器/产品/ product.php

$data['products'][] = array(
                'product_id'  => $result['product_id'],
                'thumb'       => $image,
                'name'        => $result['name'],
                'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
                'price'       => $price,
                'special'     => $special,
                'mypaycheckschedule' => $result['mypaycheckschedule'],
                'pre_pay_discount' => $result['pre_pay_discount'],
                'tax'         => $tax,
                'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
                'rating'      => $rating,
                'href'        => $this->url->link('product/product', 'product_id=' . $result['product_id'])
            );

然后在我的 的public_html /目录/视图/主题/ RGEN-Opencart的/模板/产品/ product.tpl

<?php  echo $mypaycheckschedule; ?>

0 个答案:

没有答案