Page 1 of 1
[SOLVED] Edit currency positioning, product page only.
Posted: Tue Nov 22, 2011 6:00 pm
by HATEPOLICY
Hi guys,
Tried searching all last night, could only find this:
http://forum.opencart.com/viewtopic.php?t=1210
That post is dated and Opencart system has changed since then, so I need some help please?
I am in no way a php coder, so please be gentle!
I want to do the same though, move the currency to display ONLY on the product page,
Next to the price or something, I tried a few copy paste experiments from header.tpl to product.tpl, but alas, no joy.
I am on the latest Opencart.
Any help would be greatly appreciated.
Many thanks in advance!
H.
Re: Edit currency positioning, product page only.
Posted: Wed Nov 30, 2011 1:17 am
by HATEPOLICY
bump?
anyone please? help?
Re: Edit currency positioning, product page only.
Posted: Tue Dec 06, 2011 10:10 pm
by HATEPOLICY
Bump again!
If nobody can provide any support could someone point me to place that can?
cheers.
Re: Edit currency positioning, product page only.
Posted: Tue Dec 06, 2011 11:13 pm
by uksitebuilder
edit catalog/controller/product/product.php
find
Code: Select all
$this->load->model('catalog/product');
add after
Code: Select all
if (($this->request->server['REQUEST_METHOD'] == 'POST') && isset($this->request->post['currency_code'])) {
$this->currency->set($this->request->post['currency_code']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['shipping_method']);
$this->redirect($this->request->post['redirect']);
}
$this->load->model('localisation/currency');
$this->data['currencies'] = array();
$results = $this->model_localisation_currency->getCurrencies();
foreach ($results as $result) {
if ($result['status']) {
$this->data['currencies'][] = array(
'title' => $result['title'],
'code' => $result['code'],
'symbol_left' => $result['symbol_left'],
'symbol_right' => $result['symbol_right']
);
}
}
edit catalog/view/theme/default/template/product/product.tpl
find
add after
Code: Select all
<?php if (count($currencies) > 1) { ?>
<form action="" method="post" enctype="multipart/form-data">
<div id="currency">
<?php foreach ($currencies as $currency) { ?>
<?php if (isset($currency_code)&&$currency['code'] == $currency_code) { ?>
<?php if ($currency['symbol_left']) { ?>
<a title="<?php echo $currency['title']; ?>"><b><?php echo $currency['symbol_left']; ?></b></a>
<?php } else { ?>
<a title="<?php echo $currency['title']; ?>"><b><?php echo $currency['symbol_right']; ?></b></a>
<?php } ?>
<?php } else { ?>
<?php if ($currency['symbol_left']) { ?>
<a title="<?php echo $currency['title']; ?>" onclick="$('input[name=\'currency_code\']').attr('value', '<?php echo $currency['code']; ?>').submit(); $(this).parent().parent().submit();"><?php echo $currency['symbol_left']; ?></a>
<?php } else { ?>
<a title="<?php echo $currency['title']; ?>" onclick="$('input[name=\'currency_code\']').attr('value', '<?php echo $currency['code']; ?>').submit(); $(this).parent().parent().submit();"><?php echo $currency['symbol_right']; ?></a>
<?php } ?>
<?php } ?>
<?php } ?>
<input type="hidden" name="currency_code" value="" />
<input type="hidden" name="redirect" value="index.php?route=product/product&product_id=<?php echo $this->request->get['product_id']; ?>" />
</div>
</form>
<?php } ?>
edit catalog/view/theme/default/template/common/header.tpl
find & delete
Code: Select all
<?php if (count($currencies) > 1) { ?>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
<div id="currency"><?php echo $text_currency; ?><br />
<?php foreach ($currencies as $currency) { ?>
<?php if ($currency['code'] == $currency_code) { ?>
<?php if ($currency['symbol_left']) { ?>
<a title="<?php echo $currency['title']; ?>"><b><?php echo $currency['symbol_left']; ?></b></a>
<?php } else { ?>
<a title="<?php echo $currency['title']; ?>"><b><?php echo $currency['symbol_right']; ?></b></a>
<?php } ?>
<?php } else { ?>
<?php if ($currency['symbol_left']) { ?>
<a title="<?php echo $currency['title']; ?>" onclick="$('input[name=\'currency_code\']').attr('value', '<?php echo $currency['code']; ?>').submit(); $(this).parent().parent().submit();"><?php echo $currency['symbol_left']; ?></a>
<?php } else { ?>
<a title="<?php echo $currency['title']; ?>" onclick="$('input[name=\'currency_code\']').attr('value', '<?php echo $currency['code']; ?>').submit(); $(this).parent().parent().submit();"><?php echo $currency['symbol_right']; ?></a>
<?php } ?>
<?php } ?>
<?php } ?>
<input type="hidden" name="currency_code" value="" />
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
</div>
</form>
<?php } ?>
edit: catalog/view/theme/default/stylesheet/stylesheet.css
find and delete
Code: Select all
#currency {
width: 75px;
position: absolute;
top: 15px;
left: 425px;
color: #999;
line-height: 17px;
}
BACKUP Files first
Re: Edit currency positioning, product page only.
Posted: Tue Dec 06, 2011 11:41 pm
by HATEPOLICY
Thanks ever so much UKSiteBuilder!!!
Much appreciated! I am sure it works but will report back anyway.
Edit: Just noticed you have a donate button, I will be using it this week if this works!
Many thanks again.
Re: [SOLVED] Edit currency positioning, product page only.
Posted: Wed Dec 07, 2011 12:16 am
by HATEPOLICY
Worked like a charm, nice one.
For any other n00bs like myself,
I have a custom template, so I edited the same files on it.
I'm off to buy you a few drinks Simon, thanks again
Re: [SOLVED] Edit currency positioning, product page only.
Posted: Wed Dec 07, 2011 12:21 am
by uksitebuilder
You're welcome