问题
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:
this is relatively simple if you understand the MVC (Modal, View, Controller) pattern. here are the steps required:
- 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)
- 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
来源:https://stackoverflow.com/questions/54969742/display-weight-under-price-in-product-page-search-page