Display Weight under Price in Product Page & Search page [closed]

依然范特西╮ 提交于 2019-12-13 09:29:58

问题


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:

  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



来源:https://stackoverflow.com/questions/54969742/display-weight-under-price-in-product-page-search-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!