简体   繁体   中英

Opencart 3.x - Display price in reward points - featured home

I want to display price in reward points in extensions/module/featured module in my Opencart 3.x so i made this code:

     {% if points %}
        <p class="price-pkt">Price in points is:
           <span>
           {{ text_points }} {{ points }} POINTS
           </span>
        </p>
      {% endif %} 

And also added this code to featured controller:

$data['points'] = $product_info['points'];

But Featured loop on my homepage displaying latest added product reward price for ALL products, and don't know how to solve it. Always last added product reward price is showing for all of them.

You need to pass the points for each product in the existing product array $data['products'] that is being passed to the template from the controller like this

    'price'       => $price,
    'points'      => $product_info['points'],
    'special'     => $special,

Then in the template update your code to

{% if product.points %}
  <p class="price-pkt">Price in points is:
    <span>{{ text_points }} {{ product.points }} POINTS</span>
  </p>
{% endif %}

and make sure it is inside of the product loop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM