2016-06-09 63 views
-1

如何以確認訂單顯示分類編號Opencart 2.在確認訂單中顯示分類編號

謝謝。

image here

+0

爲了避免堆棧溢出社區,我建議你回顧一個糟糕的開局[我如何問一個很好的問題?]。好的問題帶來了很好的答案,不幸的是你的問題可能對你來說似乎很清楚,但它並不是真的。 – GaijinJim

回答

0

你將不得不做以下改變。

  1. 打開文件catalog/controller/checkout/confirm.php。找到$this->load->model('extension/extension');行,並在其後面添加。 $this->load->model('catalog/product');

  2. 替換此

    $data['products'][] = array(
         'key'  => $product['key'], 
         'product_id' => $product['product_id'], 
         'name'  => $product['name'], 
         'model'  => $product['model'], 
         'option'  => $option_data, 
         'recurring' => $recurring, 
         'quantity' => $product['quantity'], 
         'subtract' => $product['subtract'], 
         'price'  => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'))), 
         'total'  => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity']), 
         'href'  => $this->url->link('product/product', 'product_id=' . $product['product_id']), 
    ); 
    

BY THIS

$cats = $this->model_catalog_product->getCatByProd($product['product_id']); 

$prefix = ''; 

foreach ($cats as $cat){ 
    $categories .= $prefix.$cat['category_id']; 
    $prefix = ', '; 
} 

    $data['products'][] = array(
      'key'  => $product['key'], 
      'product_id' => $product['product_id'], 
      'categories' => $categories, 
      'name'  => $product['name'], 
      'model'  => $product['model'], 
      'option'  => $option_data, 
      'recurring' => $recurring, 
      'quantity' => $product['quantity'], 
      'subtract' => $product['subtract'], 
      'price'  => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'))), 
      'total'  => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity']), 
      'href'  => $this->url->link('product/product', 'product_id=' . $product['product_id']), 
    ); 
  • 打開這個文件catalog/model/catalog/product.php。在裏面添加這個函數。

    public function getCatByProd($product_id) { 
    $query = $this->db->query("SELECT category_id FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'"); 
    
         return $query->rows; 
    } 
    
  • 打開此文件catalog\view\theme\default\template\checkout\confirm.tpl

  • 替換此

    <a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a> 
    

    BY本

    <a href="<?php echo $product['href']; ?>"><?php echo $product['name'].' ('.$product['categories'].')'; ?></a> 
    
    +0

    無法正常工作。在步驟6中確認訂單顯示此警報。 https://yadi.sk/i/KwdfHInDsQnDE –