Greetings to you dear visitor on the pages of our site, where we occasionally publish useful tips for opencart, and not only for this engine online store, we can find various notes that will be useful to any webmaster, both a novice developer and professionals can emphasize for themselves something new.
Today I would like to describe a simple method of outputting an opencart producer at an arbitrary location in your store. By default in the engine of this online store the manufacturer is displayed exactly in specific places, but there are situations when you need to display the manufacturer for example in the product basket.
Today, just one of the users of our site asked us for help in this matter, he needed to add a display of the manufacturer in the shopping cart, in the buyer's history, and also change the fields in the opencart order letter, so that the brand would show up there.
Development of an online store as I understood it started only recently, its subjects furniture online store, work in this store as they say no end, but in this case the task was just to show the manufacturer in an arbitrary location of the store, he certainly decided to use this field for other purposes, but still ...
PS: By the way, if you need to bring out the logo of the manufacturer opencart in the product card, I recommend reading this article by reference here.
Well, I will not, as they say, pull the cat for its virtues :), but we will start to solve the problem, especially since it is not so difficult already. Add the manufacturer, we will in this example, specifically in the order basket, in other places do everything by analogy, with the exception of some small moments.
We will make all changes only in two files:
1 2 3 |
catalog\controller\checkout\cart.php and \catalog\view\theme\ΡΠ°Π±Π»ΠΎΠ½\template\checkout\cart.tpl |
And so, first open the file of the controller cart.php
We find the line:
1 |
$this->load->model('tool/upload'); |
After which we add:
1 |
$this->load->model('catalog/product'); |
Next we need to find the line:
1 |
foreach ($products as $product) { |
And right after it, add:
1 |
$product_info = $this->model_catalog_product->getProduct($product['product_id']); |
Further we find:
1 |
$data['products'][] = array( |
And in the array below, we need to add:
1 2 |
'manufacturer' => $product_info['manufacturer'], 'manufacturer' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']), |
For example, you can insert after:
1 |
'name'Β Β Β Β Β => $product['model'],) |
That's all that needed to be done in the order basket inspector. Now we only need to bring the manufacturer to the right place in the template, and so open the file cart.tpl and add the following in the right place:
1 |
<a href="<?php echo $product['manufacturers']; ?>"><?php echo $product['manufacturer']; ?><a/> |
In this case, the customer needed to be displayed under the name of the product, so I added it after:
1 |
<a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a> |
Well, that's all, and all that needed to be done, that the manufacturer was displayed in the order basket.
Try it and you will succeed.
No Comment
You can post first response comment.