Display Weight under Price in Product Page & Searc

2019-09-24 16:01发布

i need to display Product Weight under Product price in the single product page & search page on OpenCart 3.0.2.0 .

How i can do that ?

1条回答
SAY GOODBYE
2楼-- · 2019-09-24 16:21

this is relatively simple if you understand the MVC (Modal, View, Controller) pattern. here are the steps required:

  1. you need to add the logic for fetching the product weight in the controller file and pass it to the view catalog/controller/product/product.php

on line 283 (right after the price because it is a nice place for it) add this code

$data['weight'] = $product_info['weight'] + 0 ;

(the + 0 removes the zeros and makes it looks nicer)

  1. then you need to display it in your view template file catalog/view/theme/default/template/product/product.twig on line 162 add
{{weight}}

If you don't see the changes, that is because you have twig Cache turned on. go to admin/dashboard and on the top right corner find the gear button. click it and click refresh cache. you can also turn off the cache while you are in development mode. http://joxi.ru/LmGewYZiwBW0zA

查看更多
登录 后发表回答