Page 1 of 1

How to get the currency code value on product.tpl file OC2.0

Posted: Sun Apr 26, 2015 6:29 pm
by xdomofab
I wanted to add the currency code to product.tpl on Opencart 2.0:

Code: Select all

<?php echo $this->currency->getCode(); ?>
it does not work on Opencart 2.0, how to fix it?

Re: How to get the currency code value on product.tpl file O

Posted: Sun Apr 26, 2015 6:44 pm
by OSWorX
You are selling expensive extensions and asking here for to help you?

Re: How to get the currency code value on product.tpl file O

Posted: Sun Apr 26, 2015 8:50 pm
by rph
All data needs to be injected into the view in 2.x. You can't directly access the service locator from it anymore.

Re: How to get the currency code value on product.tpl file O

Posted: Tue Apr 28, 2015 8:50 pm
by Pobb
Try putting this in controller > product.php

Code: Select all

$data['code'] = $this->currency->getCode();
and then in your product.tpl

Code: Select all

<?php echo $data['code']; ?>

Re: How to get the currency code value on product.tpl file O

Posted: Tue Mar 08, 2016 8:47 pm
by sans
How to i get currency code for opencart 2.2.0.0?
I am try this code :

Code: Select all

$data['code'] = $this->currency->getCode();
But i get error.

Re: How to get the currency code value on product.tpl file O

Posted: Tue Mar 08, 2016 9:26 pm
by ocart777
sans wrote:How to i get currency code for opencart 2.2.0.0?
I am try this code :

Code: Select all

$data['code'] = $this->currency->getCode();
But i get error.

Code: Select all

$data['code'] = $this->session->data['currency'];