Akansha
Akansha

Reputation: 1

In OpenCart, How can I customize the info visible on the product page

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

Answers (2)

HDP
HDP

Reputation: 4221

Try something like in default OpenCart code.

Step 1

Open file: catalog\language\english\product\category.php

Find:

$_['text_price']        = 'Price:';

Add after:

$_['text_reward']       = 'Reward Points:';


Step 2

Open file: catalog\controller\product\category.php

Find:

'price'       => $price,

Add after:

'points'      => $result['points'],


Step 3

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');


Step 4

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

Abdelrhman Adel
Abdelrhman Adel

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

  • First of all, you should read about the MVC design pattern, there are pretty cool MVC examples for PHP on the internet, GIYF !
  • Second, you should read this great article which explains basics of OC, Here
  • The real work:
    • Make sure that each product in the array of products to be displayed in the category page has the value of reward points (or what ever datum you want), you can check that by opening 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
    • Now in the category template file 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 loop
      foreach ($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

Related Questions