Display original currency in checkout cart total

  • Posts: 217
  • Thank you received: 4
6 years 10 months ago #285176

-- HikaShop version -- : 3.2.2

Hello,

I am trying to make own currency switcher module that will work with cache.
What I need is to display both prices everywhere, listing, product view, checkout and then I will show or hide one of them.

Only place where I still can't get both prices is cart total, as pictured bellow:



I need to have price in EURO (it is original currency) in total too.


I know where I should put the code, but I do not know the code, I tried this without success, it is always zero:
echo $this->currencyHelper->format($price->price_orig_value_without_discount_with_tax,$price->price_orig_currency_id);
echo $this->currencyHelper->format($this->full_total->prices[1]->price_value_with_tax,$this->full_total->prices[1]->price_currency_id);

Thanl you in advance,
F.

Attachments:

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
6 years 10 months ago #285197

Hi,

The variable

$this->full_total->prices[1]
doesn't exists.
You want to use
$this->full_total->prices[0]
instead.
$this->full_total->prices[0]->price_value_with_tax
contains the total in the current currency.
$this->full_total->prices[0]->price_orig_value_with_tax
should contain the total in the original currency.

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

  • Posts: 217
  • Thank you received: 4
6 years 10 months ago #285202

Hello Nicolas,

unfortunately, this is not working for me.
It is always zero.

Products are in EUR currency and my default Hikashop currency is CZK.


Do you have any other tips? Or is this variable working for you?

Thank you,
Filip

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
6 years 10 months ago #285205

Hi,

It is working when I add it to the "cart" file of the "checkout" view with the legacy checkout.
Now I don't know in which view you're doing your changes since you didn't say.
I assumed it was the cart view file of the legacy checkout since you were trying to use $this->full_total which is only there.
If you're using the new checkout and editing the view file show_block_cart, then it's not $this->full_total but $cart->full_total that you want to use.

The following user(s) said Thank You: FilipHradil

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

  • Posts: 217
  • Thank you received: 4
6 years 10 months ago #285216

Hello Nicolas,

not sure what legacy checkout means but yes, I am editing cart.php of view checkout.
The changes appear but variable is blank or zero if I use currency helper.

This is my code:

<td id="hikashop_checkout_cart_final_total_title" class="hikashop_cart_total_title hikashop_cart_title">
						<?php echo JText::_('HIKASHOP_TOTAL'); ?>
					</td>
					<td class="hikashop_cart_total_value" data-title="<?php echo Jtext::_('HIKASHOP_TOTAL'); ?>">
						<span class="hikashop_checkout_cart_final_total" style="font-size:32px;">
						<?php
							//echo $this->currencyHelper->format($this->full_total->prices[0]->price_value_with_tax,$this->full_total->prices[0]->price_currency_id);
							echo $this->full_total->prices[0]->price_orig_value_with_tax;
						?>
						</span>
						
					</td>

Do you have any other ideas what could be wrong?

I am again telling that my products are in currency CZK, main currency of hikashop is EUR and I need to get price in CZK in this variable. Both currencies are visible and active.

I tested also on testing site and the result is same.


F.

Last edit: 6 years 10 months ago by FilipHradil.

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

  • Posts: 4747
  • Thank you received: 644
  • MODERATOR
6 years 10 months ago #285243

Hello,

Let's check something, can you provide a screenshot of your Legacy settings, like on this image :



Awaiting news from you to better understand what's going on.

Regards

Last edit: 6 years 10 months ago by Philip.

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

  • Posts: 217
  • Thank you received: 4
6 years 10 months ago #285256

Hello Nicolas,

thank you, here it is.




BR,
F.

Attachments:

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
6 years 10 months ago #285258

Hi,

Add that code:
var_dump($this->full_total->prices[0]);
and you'll see all the attributes that you can use instead of price_orig_value_with_tax which apparently doesn't exist there.

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

  • Posts: 217
  • Thank you received: 4
6 years 10 months ago #285282

Hi!

Briliant idea! It seems there is no variable with original currency, here is output.



Any other ideas how to get that variable, please?


Thank you,
Filip

Attachments:

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
6 years 10 months ago #285286

Hello,

Please read carefully the Nicolas message :

and you'll see all the attributes that you can use instead of price_orig_value_with_tax which apparently doesn't exist there.

He is telling you that there is no "orig" price since there is no conversion of the price.
But he is telling you that you will have all the elements which will help you to continu your customization since you will have the available data.
Afterwards you might want to perform a conversion to another currency using the currency helper that you're using to format the price.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 217
  • Thank you received: 4
6 years 10 months ago #285326

Hello,

as I said, my products are in CZK currency. I set main currency in Hika configuration to EUR as to as there will appear two currencies in product listing and product view.

Is there any work around or configuration that will make two prices visible? Can you advise something, please?
Filip

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
6 years 10 months ago #285328

Hi,

Since the orig prices are not available there. You need to convert them.
For example:

$currencyClass = hikashop_get('class.currency');
$currencyClass->format($currencyClass->convertUniquePrice($this->full_total->prices[0]->price_value_with_tax, $this->full_total->prices[0]->price_curreny_id, XXX), XXX);
where XXX is to be replaced with the id of the currency you want to convert the price back to.

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

  • Posts: 217
  • Thank you received: 4
6 years 10 months ago #285371

Hello Nicolas,

perfect! It worked! Thank you very much.
I have a very last question, is there any way how to access this class and conversion method from banktransfer_end.php (file of plugin banktransfer) and order_creation_notification_preload.modified.php?


Thank you very muhc for all your help,
Filip

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
6 years 10 months ago #285379

Hi,

You can use the same code there, except for the variables.
in banktransfer_end, the total amount should be in $this->order->order_full_price instead of $this->full_total->prices[0]->price_value_with_tax and the currency id should be in $this->order->order_currency_id instead of $this->full_total->prices[0]->price_curreny_id
In the preload, it's the same but with $data->cart instead of $this->order

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

  • Posts: 217
  • Thank you received: 4
6 years 10 months ago #285426

Hello!

Thank you very much! I finally made my javascript no-cache currency switcher modification :)).

Thank you very much for your great and kind support!


Filip

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

Time to create page: 0.099 seconds
Powered by Kunena Forum