Reputation: 1
Okay, first I want to say that I am not a geek programmer. I am intermediate to programming. I was recently learning Php through teamtreehouse, which I have not finished yet. But instead I started making an online store from OpenCart. I watched some youtube videos and added some products, categories etc. Now I am strucked and lost my sleep, because there is no proper explanation on the web. The Problem is- On the product page I have a category of Reward Points for many products. But only thing visible on the category page is image, price, short description, Add to Cart option. I am sorry, If I am not being able to explain it properly...Below is the url of the screenshot-
http://postimg.org/image/7s413wjyd/
And also see what I want to make-
http://postimg.org/image/rggxj7hq5/
Is there a way of doing it through the admin page of opencart?? If not then please guide me how it will work by code. I am new to php too, but it will make me understand. Please help me out.
Upvotes: 0
Views: 1375
Reputation: 4221
Try something like in default OpenCart code.
Open file: catalog\language\english\product\category.php
Find:
$_['text_price'] = 'Price:';
Add after:
$_['text_reward'] = 'Reward Points:';
Open file: catalog\controller\product\category.php
Find:
'price' => $price,
Add after:
'points' => $result['points'],
In the same file: catalog\controller\product\category.php
Find:
$data['text_price'] = $this->language->get('text_price');
Add after:
$data['text_reward'] = $this->language->get('text_reward');
Open File: catalog\view\theme\default\template\product\category.tpl
Find:
<?php if ($product['price']) { ?>
<p class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
<?php if ($product['tax']) { ?>
<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
<?php } ?>
</p>
<?php } ?>
Add after:
<p><?php echo $text_reward; ?> <?php echo $product['points']; ?></p>
and then check it.
Upvotes: -1
Reputation: 1187
Is there a way of doing it through the admin page of opencart??
No
If not then please guide me how it will work by code
It's a very simple task but you will not be able to do it if you are not aware of web development basics
ControllerProductCategory class @ catalog/controller/product/category.php
and dumping the variable $data['products']
, if it's there then step 1 in the real work is done, if not, you will need to change the model function getProducts()
in ModelCatalogProduct class @ catalog/model/catalog/product.php
catalog/view/theme/your theme folder/template/product/category.tpl
, access the value of reward points and display it the product html div, you will find it enclosed in this loopforeach ($products as $product) {
That may seem too much for you to learn (MVC and all that stuff...), but you have to climb the ladder, Good Luck !
Upvotes: 1