Post by tinaf » Wed Oct 03, 2018 3:15 am

Hello,
I've added the weight for each product in ounces to the product page. I'm SO close! Can anyone tell me how to change the number format to 2? I've tried a variety of things but it's not working so I'm admitting defeat and asking for help :)

Added

Code: Select all

$data['weight'] = $product_info['weight'];
to catalog/controller/product/product.php
Added

Code: Select all

<li>{{ weight }} oz.</li>
to product/product in theme editor
Resulted in showing 4.600000 oz. (or weight for that product) which is exactly what I want, just with fewer decimal points.

Thanks! Tina

Newbie

Posts

Joined
Thu Jun 07, 2018 7:46 am

Post by tinaf » Wed Oct 03, 2018 3:20 am

ALSO - same topic but different location. I would also like to add the weight to the grid/list view of products

Newbie

Posts

Joined
Thu Jun 07, 2018 7:46 am

Post by IP_CAM » Wed Oct 03, 2018 1:40 pm

Well, it will not work in OC-2+3, as it comes, but it gives you a good inside Look,
where things have to be added, to make some weight-code work. I just walked over it
tonight by accident in my Archive, and so, it might at least be of use for
someone else too ... :D
Ernie

Attachments


For Sale: Turnkey URLs with Opencart installed
My present Opencart Testsite: http://www.velomech.ch/shop/
Attacker IP Blocks are denied from further access to my Sites!
Just contact me for more Information at: jti@jacob.ch
710 FREE OC Extension-Repositories - from OC v.1.5.x up
on the largest Opencart-Mod Github Site: https://github.com/IP-CAM
Image


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by paulfeakins » Wed Oct 03, 2018 5:29 pm

tinaf wrote:
Wed Oct 03, 2018 3:15 am
Can anyone tell me how to change the number format to 2?
You have to understand that every template has a corresponding controller.

Change the use number_format($your_weight, 2) in there and it should do it.

Once tested and working, you should move this to a vQmod or OCMOD.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by straightlight » Wed Oct 03, 2018 5:59 pm

You can also refer to this TWIG documentation to edit your number format directly into your TWIG files: https://twig.symfony.com/doc/2.x/filter ... ormat.html

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member
Online

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 23 guests