0

I want to create 1 or 2 more product templates for some products in my Opencart store. My supplier has certain restrictions on which products can and can't be sold online.

  • Some products are allowed to be sold online and prices can be displayed
  • Some products can have a price online, but no add to cart button and display "available in-store only"
  • Some products can't have price or add to cart

Would it be possible to make 2 product templates that change depending on the assigned stock status? Like the OP in the linked post, I also want something that can be changed in the options menu.

OpenCart - View alternate product template based on arbitrary product field

Community
  • 1
  • 1
  • The answer to your question is: *Yes, it would be possible*. With some coding, of course, since OpenCart does not allow to change the product templates regarding it's stock status from default. – shadyyx Aug 18 '14 at 08:44

1 Answers1

1

You can make specific template for what products you don't want to sell without price or add to cart button.

There is a way, you can make specific template for each product. You need to edit /catalog/controller/product/product.php and find the line:

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/product/product.tpl';
        } else {
            $this->template = 'default/template/product/product.tpl';
        }

and replace with:

 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
        '/template/product/product.tpl';

            $this->template = $this->config->get('config_template') . '/template/product/product_' . $this->request->get['product_id'] . '.tpl';
            if (!file_exists(DIR_TEMPLATE . $this->template)) {
            $this->template = $this->config->get('config_template') . '/template/product/product.tpl';
}
            } else {
                $this->template = 'default/template/product/product.tpl';
            }

Now you can create the specific template with easy and no need to always modificate OpenCart when you need a unique page. In /catalog/view/theme/yourtemplate/template/product/product.php , if you want specific template for one product only just make another file called product_id.tpl