Post by sixpoint » Sun Oct 15, 2017 8:04 pm

Hello, is there a way in OC3 to show reward points rather than price for products in the category view and on the featured products on the home page?

Newbie

Posts

Joined
Sat Oct 14, 2017 4:54 pm

Post by straightlight » Sun Oct 15, 2017 8:33 pm

For demonstration purposes;

In catalog/controller/extension/module/featured.php file,

find:

Code: Select all

if ((float)$product_info['special']) {
						$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
					} else {
						$special = false;
					}
add below:

Code: Select all

if ((int)$product_info['reward']) {
						$reward = (int)$product_info['reward'];
					} else {
						$reward = false;
					}
Then, find:

Code: Select all

'special'     => $special,
add below:

Code: Select all

'reward'       => $reward,
In catalog/view/theme/<your_theme>/template/extension/module/featured.twig file,

add:

Code: Select all

{% if reward %}
<p>{{ reward }}</p>
{% endif %}
Between these codes and where and when you want the reward to be shown:

Code: Select all

{% if product.price %}
        <p class="price">
          {% if not product.special %}
          {{ product.price }}
          {% else %}
          <span class="price-new">{{ product.special }}</span> <span class="price-old">{{ product.price }}</span>
          {% endif %}
          {% if product.tax %}
          <span class="price-tax">{{ text_tax }} {{ product.tax }}</span>
          {% endif %}
        </p>
        {% endif %}
        
In catalog/controller/product/category.php file,

find:

Code: Select all

if ((float)$result['special']) {
					$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
				} else {
					$special = false;
				}
add below:

Code: Select all

if ((int)$result['reward']) {
					$reward = (int)$result['reward'];
				} else {
					$reward = false;
				}
Then, find:

Code: Select all

'special'     => $special,
add below:

Code: Select all

'reward'       => $reward,
In catalog/view/theme/<your_theme>/template/product/category.twig file,

find:

Code: Select all

{% if product.rating %}
add above:

Code: Select all

{% if reward %}
<p>{{ reward }}</p>
{% endif %}
Last edited by straightlight on Sun Oct 15, 2017 9:56 pm, edited 1 time in total.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by sixpoint » Sun Oct 15, 2017 9:42 pm

Thanks for spending the time providing this, i've been through all the steps but it doesn’t seem to be working - I have tried clearing the theme cache.

The only thing I noticed is this bit:

In catalog/controller/extension/product/category.php file,

I didn’t have that but added the code to:

catalog/controller/product/category.php

Its the default theme and I haven’t done any other customisation except to hide the price in the product detail view.

Thanks in advance

Newbie

Posts

Joined
Sat Oct 14, 2017 4:54 pm

Post by straightlight » Sun Oct 15, 2017 9:58 pm

You are correct for the category path. it has now been updated. However, ensure to clear all caches, not just one cache.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Oct 15, 2017 10:44 pm

In addition, the reward must also reflect from the Opencart admin product where the product to category is being linked to. A reward must be added for that particular product so for the catalog-end to notice the differences.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by sixpoint » Mon Oct 16, 2017 12:50 am

Sorry still no luck, I have clearing the cache using the tools in the dashboard and also cleared browser cache and cookies.

I have also tried installing a new OC 3 in my local environment and carrying out your instructions again but I still don’t see reward points in the featured and category product views despite clearing cache in dashboard, browser and from the storage folder.

I’m not sure what I could be doing wrong, any ideas?

Newbie

Posts

Joined
Sat Oct 14, 2017 4:54 pm

Post by straightlight » Mon Oct 16, 2017 1:05 am

I’m not sure what I could be doing wrong, any ideas?
Have you followed the instructions on the above regarding the product reward points from the admin products page?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by sixpoint » Mon Oct 16, 2017 9:05 pm

Im not 100% sure what you mean there but I can confirm that all products have a reward points value assigned to them and I can see this in the product detail view where I have successfully hidden the price and just show the reward points.

Image

Newbie

Posts

Joined
Sat Oct 14, 2017 4:54 pm
Who is online

Users browsing this forum: SohBH and 378 guests