Two independent currency for product

  • Posts: 17
  • Thank you received: 0
8 years 5 months ago #257177

I have two currency in Hika Shop (PLN ane Euro). Main currency is PLN but I for some products it need to be only in Euro.
When I set price on product cart on Euro (and is't only one price!) Hika Shop shows both of them PLN and Euro (with the same value! ) - I don't want that. All my product has got one price in one currency but for some of thme it will be PLN and some of them - Euro. Currency switcher is not good solution for me...

How to make currency more independent?
I need to have both currency in my shop but each product has to have only one currency (or PLN or Euro).

Thank You in advance.
Greg

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

  • Posts: 83806
  • Thank you received: 13571
  • MODERATOR
8 years 5 months ago #257191

Hi,

I don't see how that would work then.
If the current currency of the customer is EUR and he displays a product with only the PLN price entered, what should it do then ?
What if the customer add to his cart products with prices with different currencies ?
If we were doing what you say and not converting automatically the prices when the price is missing in the current currency of the customer, the system wouldn't be able to sum the prices of the products in different currencies in the cart or it wouldn't mean anything.
That's why the system works like it does.

Last edit: 8 years 5 months ago by nicolas.

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

  • Posts: 17
  • Thank you received: 0
8 years 5 months ago #257237

I'm sorry I forgot to tell you that I use HikaShop only for product directory. You can't buy antything via my page, only send questions about products. Of course in ordinary shop it's clear... but not on my web. Can I somehow break standard currency functionality as I wrote?

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

  • Posts: 83806
  • Thank you received: 13571
  • MODERATOR
8 years 5 months ago #257247

Hi,

Then I see two possible solutions:
1. Instead of setting up prices for your products, you could instead create a custom field of the table "product" via the menu Display>Custom fields and enter the price with the format and currency you want in the field in each product in your backend and it would then display like that on your frontend.

2. You could edit the file "listing_price" of the view "product" via the menu Display>Views to remove the display of the price when there is an orig (original) price so that it doesn't display the converted price and only the one you entered in the backend.
The modifications will have to be in that piece of code:

echo '<span class="'.implode(' ',$classes).'"'.$attributes.'>';

			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($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_AFTER_ORIG');
			}
			echo '</span> ';

The following user(s) said Thank You: netica

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

  • Posts: 17
  • Thank you received: 0
8 years 5 months ago #257545

It works, thank you.

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

  • Posts: 13
  • Thank you received: 1
4 years 10 months ago #321539

I use hikashop 4.3 and I changed listin_price like this:

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	4.3.0
 * @author	hikashop.com
 * @copyright	(C) 2010-2020 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
$config =& hikashop_config();
$class = (!empty($this->row->prices) && count($this->row->prices) > 1) ? ' hikashop_product_several_prices' : '';
if(!empty($this->row->has_options))
	$class.=' hikashop_product_has_options';

if(isset($this->element->main->product_msrp) && !(@$this->row->product_msrp > 0.0))
	$this->row->product_msrp = $this->element->main->product_msrp;
if(isset($this->row->product_msrp) && $this->row->product_msrp > 0.0 && hikaInput::get()->getCmd('layout') == 'show' && $this->params->get('from_module','') == '') {
	$show_msrp = true;
	$mainCurr = $this->currencyHelper->mainCurrency();
	$currCurrency = hikashop_getCurrency();
	if($currCurrency == $mainCurr && !empty($this->row->prices)) {
		$price = reset($this->row->prices);
		if(!empty($this->unit) && isset($price->unit_price))
			$price =& $price->unit_price;
		if($this->row->product_msrp == $price->price_value_with_tax) {
			$show_msrp = false;
		}
		unset($price);
	}
}

if(!empty($show_msrp)) {
?>
	<span class="hikashop_product_msrp_price hikashop_product_price_full">
		<span class="hikashop_product_msrp_price_title"><?php
			echo JText::_('PRODUCT_MSRP_BEFORE');
		?></span>
		<span class="hikashop_product_price"><?php
			$mainCurr = $this->currencyHelper->mainCurrency();
			$currCurrency = hikashop_getCurrency();
			$msrpCurrencied = $this->currencyHelper->convertUniquePrice($this->row->product_msrp, $mainCurr, $currCurrency);
			if($msrpCurrencied == $this->row->product_msrp)
				echo $this->currencyHelper->format($this->row->product_msrp, $mainCurr);
			else {
				echo $this->currencyHelper->format($msrpCurrencied, $currCurrency);
				if($this->params->get('show_original_price'))
					echo ' ('.$this->currencyHelper->format($this->row->product_msrp, $mainCurr).')';
			}
		?></span>
	</span>
<?php
}
?>
	<span class="hikashop_product_price_full<?php echo $class; ?>"><?php

	if(empty($this->row->prices)) {
		echo JText::_('FREE_PRICE');
	} else {
		$first = true;
		echo JText::_('PRICE_BEGINNING');
		$i = 0;

		if(!empty($show_msrp)) {
			echo '<span class="hikashop_product_our_price_title">'.JText::_('PRODUCT_MSRP_AFTER').'</span> ';
		}

		if($this->params->get('price_with_tax', 3) == 3) {
			$this->params->set('price_with_tax', (int)$config->get('price_with_tax'));
		}

		$microDataForCurrentProduct = false;

		foreach($this->row->prices as $k => $price) {
			if($first)$first=false;
			else echo JText::_('PRICE_SEPARATOR');
			if(!empty($this->unit) && isset($price->unit_price)) {
				$price =& $price->unit_price;
			}
			if(empty($price->price_currency_id))
				continue;
			$start = JText::_('PRICE_BEGINNING_'.$i);
			if($start != 'PRICE_BEGINNING_'.$i) {
				echo $start;
			}
			if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $price->price_min_quantity > 1) {
				echo '<span class="hikashop_product_price_with_min_qty hikashop_product_price_for_at_least_'.$price->price_min_quantity.'">';
			}

			$classes = array('hikashop_product_price hikashop_product_price_'.$i);
			if(!empty($this->row->discount)) {
				$classes[]='hikashop_product_price_with_discount';
			}

			if(!empty($this->row->discount)) {

				if(in_array($this->params->get('show_discount'), array(1, 4))) {
					echo '<span class="hikashop_product_discount">'.JText::_('PRICE_DISCOUNT_START');
					if(bccomp($this->row->discount->discount_flat_amount, 0, 5) !== 0) {
						echo $this->currencyHelper->format( -1 * $this->row->discount->discount_flat_amount, $price->price_currency_id);
					} elseif(bccomp($this->row->discount->discount_percent_amount, 0, 5) !== 0) {
						echo -1*$this->row->discount->discount_percent_amount.'%';
					}
					echo JText::_('PRICE_DISCOUNT_END').'</span>';
				}
				if(in_array($this->params->get('show_discount'), array(2, 4))) {
					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') && !empty($price->price_orig_value_without_discount)) {
							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>';
				} elseif($this->params->get('show_discount') == 3) {

				}
			}

			$attributes = '';
			if(!empty($this->element->product_id) && !$microDataForCurrentProduct) {
				$round = $this->currencyHelper->getRounding($price->price_currency_id, true);
				$prefix = 'data-';
				$microDataForCurrentProduct = true;
				if(empty($this->displayed_price_microdata)) {
					$this->displayed_price_microdata = true;
					$prefix = '';
				}
				if($this->params->get('price_with_tax')) {
					$attributes = ' '.$prefix.'itemprop="price" '.$prefix.'content="'. str_replace(',','.',$this->currencyHelper->round($price->price_value_with_tax, $round, 0, true)) .'"';
				} else {
					$attributes = ' '.$prefix.'itemprop="price" '.$prefix.'content="'. str_replace(',','.',$this->currencyHelper->round($price->price_value, $round, 0, true)) .'"';
				}
			}
			echo '<span class="'.implode(' ',$classes).'"'.$attributes.'>';
			echo '<span class="tomanprice">';
			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');
			}
			
			echo '</span> ';
			if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $this->params->get('per_unit', 1)) {
				if($price->price_min_quantity > 1) {
					echo '<span class="hikashop_product_price_per_unit_x">'.JText::sprintf('PER_UNIT_AT_LEAST_X_BOUGHT',$price->price_min_quantity).'</span>';
				} else {
					echo '<span class="hikashop_product_price_per_unit">'.JText::_('PER_UNIT').'</span>';
				}
			}
			if($this->params->get('show_price_weight')){
				if(!empty($this->element->product_id) && isset($this->row->product_weight) && bccomp($this->row->product_weight, 0, 3)) {

					echo JText::_('PRICE_SEPARATOR').'<span class="hikashop_product_price_per_weight_unit">';
					if($this->params->get('price_with_tax')){
						$weight_price = $price->price_value_with_tax / $this->row->product_weight;
						echo $this->currencyHelper->format($weight_price, $price->price_currency_id).' / '.JText::_($this->row->product_weight_unit);
					}
					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')) {
						$weight_price = $price->price_value / $this->row->product_weight;
						echo $this->currencyHelper->format($weight_price, $price->price_currency_id).' / '.JText::_($this->row->product_weight_unit);
					}
					if($this->params->get('price_with_tax') == 2) {
						echo JText::_('PRICE_AFTER_TAX');
					}
					echo '</span>';
				}
			}
			if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $price->price_min_quantity > 1) {
				echo '</span>';
			}
			if($this->params->get('show_original_price') && !empty($price->price_orig_value)) {
			echo '<span class="hikashop_orig_price">';
				
				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 '</span>';
			}
			echo '</span> ';
			$end = JText::_('PRICE_ENDING_'.$i);
			if($end != 'PRICE_ENDING_'.$i) {
				echo $end;
			}
			$i++;
		}
		echo JText::_('PRICE_END');
	}
	?></span>

and then in my template styles I add
.tomanprice
{display:none;
}

The following user(s) said Thank You: nicolas

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

Time to create page: 0.075 seconds
Powered by Kunena Forum