简体   繁体   中英

how to display the upc in product page with opencart3?

I want to display the upc in product page with opencart 3. How do I do that?

I added the below code into my template file /catalog/view/theme/default/template/product/product.twig ,but it doesn't work.

{% if upc %}
    {{ upc }}
{% endif %}

Please do not forget to backup these files first.

You have to add upc as a variable to the controller first and then echo it in the template. in order to do that: first edit controller file:

/catalog/controller/product/product.php

and search for

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

after that add:

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

and save the file.

After that your code in template file that you mentioned will work.

ps: by this approach you lose these changes if you update opencart.A better approach would be to make an ocmod extension for it.

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