0

I have tried to add some musics in my site which is free download products...

In admin->catalog->downloads (Uploaded Music files)

And in admin->catalog->products (Edit product) & link-> (added download file)

But it not shown in the Site it shows add to cart behaves like other products..

Kevin
  • 13
  • 9
  • Bro Download is only available after the order is completed. So once the order status is complete, customer can login in to their profile and download file form download section – Ramesh Mar 12 '15 at 05:08

1 Answers1

1

you have to edit three pages(model, controller, template), After adding download file from admin in product

Add this In opencart2\catalog\controller\product\product.php

inside index() function or after line 159

$download_m = $this->model_catalog_product->download_m($product_id);
    if(!empty($download_m)){
    $data['download_m'] = $this->url->link('account/download/download', 'download_id=' . $download_m['download_id'], 'SSL');}

Add this in opencart2\catalog\model\catalog\product.php
in this class ModelCatalogProduct extends Model {

public function download_m($product_id) {
    $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_download WHERE product_id = '" . (int)$product_id . "'");
    $sql = "SELECT * FROM " . DB_PREFIX . "product_to_download WHERE product_id = '" . (int)$product_id . "'";
    if ($query->num_rows) {
      return array(
        'product_id'       => $query->row['product_id'],        
        'download_id'      => $query->row['download_id']
      );
    } 
  }

At last Add in opencart2\catalog\view\theme\default\template\product\product.tpl

After < h1>< ?php echo $heading_title; ?> or line 138

<?php if(!empty($download_m)){ ?>
          <li><a href="<?php echo $download_m; ?>">download here</a></li>
          <?php } ?>

enter image description here

StackQA
  • 231
  • 1
  • 13