Post by johnzhang » Thu Jun 02, 2011 11:32 am

How i get the currency code value on product.tpl file ?

<?php echo $currency['code']; ?> only avaliable for header ,
if i want add to product.tpl file ?
how to do this ?

New member

Posts

Joined
Sun Apr 18, 2010 11:02 am


Post by Qphoria » Fri Jun 03, 2011 12:35 pm

Code: Select all

<?php echo $this->currency->getCode(); ?>

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by xdomofab » Sun Apr 26, 2015 6:21 pm

Qphoria wrote:

Code: Select all

<?php echo $this->currency->getCode(); ?>
It did not work on Opencart 2.0, how to fix it? thank you for your reply. :)

Opencart Development & Consult:
All in One SEO Package: making your Opencart SEO friendly
Product Rich Snippets: Breadcrumb, Product & Product Reviews
Custom Titile H1 Tag: custom category title, h1, bottom description and product title
Optimize Site URL Architecture: unique url w/breadcrumb, seo friendly url architecture


New member

Posts

Joined
Wed Jun 05, 2013 11:03 am

Post by Qphoria » Wed Apr 29, 2015 4:13 am

xdomofab wrote:
Qphoria wrote:

Code: Select all

<?php echo $this->currency->getCode(); ?>
It did not work on Opencart 2.0, how to fix it? thank you for your reply. :)
In 2.x, there is a layer separation between view and library calls so you can no longer make direct function calls to the instantiated objects. Instead you must call the function from the controller and make it visible to the view in its own variable.

For 2.x

1. EDIT: catalog/controller/product/product.php
2. FIND:

Code: Select all

public function index() { 
3. AFTER, ADD

Code: Select all

$data['currency_code'] = $this->currency->getCode();
4. EDIT: catalog/view/theme/YOURTHEME/template/product/product.tpl
5. PASTE WHERE YOU WANT IT:

Code: Select all

<?php echo $currency_code; ?>

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 44 guests