VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: veselinovm on September 07, 2022, 17:37:35 PM

Title: Display 2 currencies in product, category and cart
Post by: veselinovm on September 07, 2022, 17:37:35 PM
Hi,
I am using VM: 3.8.6 and Joomla 3.10.11

In Croatia now, because of introducing Euro,  it is mandatory by law to show both currencies in webshop.
What to change in order to show, beside vendor currency (Croatian kuna), also Euro. In Configuration it is set to be muli currency and currency modul is working, but need to be displayed in a same time both currencies.

Thank you,
Milos
Title: Re: Display 2 currencies in product, category and cart
Post by: pinochico on September 07, 2022, 18:28:20 PM
find on forum
last time was there
Title: Re: Display 2 currencies in product, category and cart
Post by: veselinovm on September 08, 2022, 08:37:45 AM
Hi Pinochio,
Thank you for your answer. I did search first, but could not find suitable solution.
There is thread with swithcer, which is native solution, but I need to be dispayed both prices at the same time.
There is also solution that works only on productdisplay view, not on products.php and cart.
If you seen correct solution, please share a link.
Thank you,
Milos
Title: Re: Display 2 currencies in product, category and cart
Post by: pinochico on September 10, 2022, 18:10:30 PM
https://www.zelenazeme.cz

EUR and CZK
Is this what do you want?
Title: Re: Display 2 currencies in product, category and cart
Post by: veselinovm on September 12, 2022, 13:46:28 PM
Hi,
yes, similar...
Showing same price in different currency on category, productDetail and cart view.
I can make it in productDetail view with solution from : https://stackoverflow.com/questions/8826711/how-to-display-2-prices-in-different-currencies-for-an-item-invirtuemar/8836484#8836484 (https://stackoverflow.com/questions/8826711/how-to-display-2-prices-in-different-currencies-for-an-item-invirtuemar/8836484#8836484)
but in cart dont know how to make it...
in cart view, price is displayed with this code:

echo $this->currencyDisplay->createPriceDiv ('discountedPriceWithoutTax', '', $prow->prices, FALSE, FALSE, 1.0, false, true);

and shows price in selected currency. How to change that line to show in "hard coded"currency (eur)?

Thank you,
Milos
Title: Re: Display 2 currencies in product, category and cart
Post by: Milbo on September 12, 2022, 22:57:46 PM
You must do this with a template override, but the rest is quite "simpel".

Just use the currency object correctly. The normal thing is

echo $currency->createPriceDiv ('discountedPriceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices);


You see there the $currency, this is the currency object. Just create on top of the layout your own, with the croation currency.

$currencyCroatian  = CurrencyDisplay::getInstance(191, 1);
[code]

and then just use
[code]
echo $currencyCroatian  ->createPriceDiv ('discountedPriceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices);


To display the converted price. ahh of course your store runs in croatian currency already. Then you just need to replace the 191 (id of croation currency) to 47 for the eur currency data.
Title: Re: Display 2 currencies in product, category and cart
Post by: veselinovm on September 13, 2022, 14:14:27 PM
Excellent!
work perfectly!
Thank you very much for your help!