Removing System Currency to Swow only Product Currency

  • Posts: 25
  • Thank you received: 0
4 years 1 month ago #315484

Hi,

I have seen there have been a number of threads on this but all seem a few years ago.

I know where I need to edit but all attempts using other posts info have failed.

Can you please let me know what in the code I need to edit to remove the original currency to only show the currency selected in the product, not the currency in the system settings.

Start and end lines of the code that needs to be replaced would really help.

Many thanks in advance.

<?php
/**
* @package HikaShop for Joomla!
* @version 4.2.2
* @author hikashop.com
* @copyright (C) 2010-2019 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><span class="hikashop_product_price_full">
<?php

if(empty($this->row->prices)){
echo JText::_('FREE_PRICE');
} else {
$config =& hikashop_config();

$first = true;
echo JText::_('PRICE_BEGINNING');
foreach($this->row->prices as $i => $price) {
if($first) $first = false;
else echo JText::_('PRICE_SEPARATOR');

if(!empty($this->unit) && isset($price->unit_price)) {
$price = $price->unit_price;
}
if(!isset($price->price_currency_id)) $price->price_currency_id = hikashop_getCurrency();

$classes = array('hikashop_product_price hikashop_product_price_'.$i);
if(!empty($this->row->discount)) {
$classes[]='hikashop_product_price_with_discount';
}
echo '<span class="'.implode(' ',$classes).'">';
if($this->params->get('price_with_tax')){
echo $this->currencyHelper->format(@$price->price_value_with_tax, $price->price_currency_id);
}
if($this->params->get('price_with_tax') == 2) {
echo JText::_('PRICE_BEFORE_TAX');
}
if($this->params->get('price_with_tax') == 2 || !$this->params->get('price_with_tax')) {
echo $this->currencyHelper->format(@$price->price_value, $price->price_currency_id);
}
if($this->params->get('price_with_tax') == 2) {
echo JText::_('PRICE_AFTER_TAX');
}
if((int)$this->params->get('show_original_price', -1) == -1) {
$defaultParams = $config->get('default_params');
$this->params->set('show_original_price', $defaultParams);
}
if($this->params->get('show_original_price') && !empty($price->price_orig_value)) {
echo JText::_('PRICE_BEFORE_ORIG');
if($this->params->get('price_with_tax')) {
echo $this->currencyHelper->format($price->price_orig_value_with_tax, $price->price_orig_currency_id);
}
if($this->params->get('price_with_tax') == 2) {
echo JText::_('PRICE_BEFORE_TAX');
}
if($this->params->get('price_with_tax') == 2 || !$this->params->get('price_with_tax')) {
echo $this->currencyHelper->format($price->price_orig_value,$price->price_orig_currency_id);
}
if($this->params->get('price_with_tax') == 2) {
echo JText::_('PRICE_AFTER_TAX');
}
echo JText::_('PRICE_BEFORE_ORIG');
}
echo '</span> ';

if(!empty($this->row->discount) && isset($price->price_value_without_discount_with_tax)) {
if($this->params->get('show_discount', 3) == 3) {
$defaultParams = $config->get('default_params');
$this->params->set('show_discount', $defaultParams);
}
if($this->params->get('show_discount') == 1) {
echo '<span class="hikashop_product_discount">'.JText::_('PRICE_DISCOUNT_START');
if(bccomp($this->row->discount->discount_flat_amount, 0, 5) !== 0) {
if(!$this->unit)
$this->row->discount->discount_flat_amount = $this->row->discount->discount_flat_amount * $this->row->cart_product_quantity;
echo $this->currencyHelper->format(-1 * $this->row->discount->discount_flat_amount, $price->price_currency_id);
} else {
echo (-1 * $this->row->discount->discount_percent_amount) . '%';
}
echo JText::_('PRICE_DISCOUNT_END').'</span>';
} elseif($this->params->get('show_discount') == 2) {
echo '<span class="hikashop_product_price_before_discount">'.JText::_('PRICE_DISCOUNT_START');
if($this->params->get('price_with_tax')) {
echo $this->currencyHelper->format($price->price_value_without_discount_with_tax, $price->price_currency_id);
}
if($this->params->get('price_with_tax') == 2) {
echo JText::_('PRICE_BEFORE_TAX');
}
if($this->params->get('price_with_tax') == 2 || !$this->params->get('price_with_tax')) {
echo $this->currencyHelper->format($price->price_value_without_discount,$price->price_currency_id);
}
if($this->params->get('price_with_tax') == 2) {
echo JText::_('PRICE_AFTER_TAX');
}
if($this->params->get('show_original_price') && !empty($price->price_orig_value_without_discount_with_tax)) {
echo JText::_('PRICE_BEFORE_ORIG');
if($this->params->get('price_with_tax')) {
echo $this->currencyHelper->format($price->price_orig_value_without_discount_with_tax,$price->price_orig_currency_id);
}
if($this->params->get('price_with_tax') == 2) {
echo JText::_('PRICE_BEFORE_TAX');
}
if($this->params->get('price_with_tax') == 2 || !$this->params->get('price_with_tax')) {
echo $this->currencyHelper->format($price->price_orig_value_without_discount,$price->price_orig_currency_id);
}
if($this->params->get('price_with_tax') == 2) {
echo JText::_('PRICE_AFTER_TAX');
}
echo JText::_('PRICE_AFTER_ORIG');
}
echo JText::_('PRICE_DISCOUNT_END').'</span>';
}
}
}
echo JText::_('PRICE_END');
}
?></span>

Please Log in or Create an account to join the conversation.

  • Posts: 81362
  • Thank you received: 13037
  • MODERATOR
4 years 1 month ago #315513

Hi,

There should be no code to change.
You normally just have to turn off the corresponding setting in the HikaShop configuration and in the settings of your menu items.

Now, in that view file, you can change the code:
$this->params->get('show_original_price')
to:
false
and that will remove the price with the original currency.

Please Log in or Create an account to join the conversation.

  • Posts: 25
  • Thank you received: 0
4 years 1 month ago #315518

Hi Nicholas,

Thank you for your response.

To clarify I want to show the price in the currency that is set in the product, not the currency that is set in the global settings? I have managed to get it to only show the global currency following the information found on the fourms, but I did not see the info for getting the price to show only the product currency.

As vendors are selling in their own country their is no need for their prices to show our currency here in the UK.

from previous responses it had been mentioned that what if a basket only products from different vendors in different currencies. As we are restricting the cart to one vendor this issue does not exist.

Does the above work for either only showing the product currency or the vendor currency ?

thanks

Mike

Please Log in or Create an account to join the conversation.

  • Posts: 81362
  • Thank you received: 13037
  • MODERATOR
4 years 1 month ago #315526

Hi,

When you arrive on the website, HikaShop will select for you a currency. By default it's the currency you have configured in the HikaShop configuration as "main currency".
You can configure the "geolocation" plugin to set the currency of the customer based on his country (using his IP address).
You can also enable the HikaShop currency switcher to let him select the currency in which he will see the prices.
The goal is that even if you have a vendor selling his products in RUB, a French customer will see the prices in EUR since when they will pay it will be in EUR.
Since you don't have that case, how about using the geolocation plugin to force the currency ? It will help but it won't be perfect.
Ideally, you would need to develop a plugin in order to force the currency currency by looking at the products in the cart when the cart is being loaded.

I don't think that changing the views of HikaShop to force the currency of the price being displayed will be enough since the price that will be sent to the payment gateway and recorded in the order will still be in the current currency, and not the original one.

Please Log in or Create an account to join the conversation.

  • Posts: 25
  • Thank you received: 0
4 years 1 month ago #315540

Hi,

Thank you for that and can see how that would work for all 99.9% of cases.

Its not quite what we need as we have created a currency for the Pts so wanted it to be that only for some products points would be the only payment method.

Thank you fo your help and I think we will have to go down the route as you advise of a plug-in that can force certain products to only show the product currency.

Thank you for your help on this and possible solutions.

Much appreciated.

Mike

Please Log in or Create an account to join the conversation.

Time to create page: 0.052 seconds
Powered by Kunena Forum