Force currency based on country ?

  • Posts: 35
  • Thank you received: 1
12 years 3 months ago #60934

Hello,

I'm looking to build a shop with Hikashop, perhaps the business version. I looked into the geolocation plugin and it looks interesting. Basically, I need:

1- Specific prices by currency
2- Force the currency based on users location. This could be done with either the geolocation plugin from what I can see but a simple Country selection box would suffice - In that case, I guess I would have to create my own module?

So my question is, in either case, will I be able to force the country upon checkout to the one determined in 2 above? And not give the user the possibility to change it...

Thanks!

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

  • Posts: 13201
  • Thank you received: 2322
12 years 3 months ago #60980

Hi bohemier,

In HikaShop, you can set different prices by currency.
And you can force a currency based on the user location, you need the plugin geolocation. It will select automatically the currency and the user couldn't find it, or as you said, you can create your own module to select a country and then force the currency.

ps: the documentation for the geolocation plugin (I think you already read this)
http://www.hikashop.com/en/support/documentation/76-hikashop-geolocation.html

Last edit: 12 years 3 months ago by Xavier.

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

  • Posts: 35
  • Thank you received: 1
12 years 3 months ago #61012

Hello Xavier,

Thanks for the reply, yes I read that. My question was: Will the user be able to change his country when entering his address upon checkout?

Thanks

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

  • Posts: 82819
  • Thank you received: 13366
  • MODERATOR
12 years 3 months ago #61065

Yes, he will be able to change his country.
In fact, that's two different things.
When the geoloc plugin sets the zone of the user it's his default zone.
Once the user enters his address, the zone of the user will be based on his address.
However, the current currency won't change if the user has an address with a zone different from his geoloced zone.

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

  • Posts: 35
  • Thank you received: 1
12 years 2 months ago #61159

Thanks for the folowup Nicolas. So this will be a problem for me that I will need to fix. My client doesn't want a customer from the US to order something, pay in USD but have it shipped to UK for instance. Is there something I can do to fix this? This is why I need a country selection box in my store. Having the geolocation automatically set the country is a nice extra, but the main point for me is the country, and once the country is chosen, the currency should also be fixed.

Thanks!

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

  • Posts: 82819
  • Thank you received: 13366
  • MODERATOR
12 years 2 months ago #61239

You will first have to create a module with the country selection.
Make sure that your use the zone namekeys as in the hikashop_zone table of the database for your countries.
When you get the selection, you need to set the currency like that:
$app=&JFactory::getApplication();
$app->setUserState( 'com_hikashop.currency_id',$currency_id);
And store the country selected in the session.
Then, in the file "custom_fields" of the view "user" you will have to add something like that:
$this->address->address_country = $_SESSION;
in order to set the default country value and then add a line CSS to hide the field on the address form.
You will have to do something similar in the "form" file of the view "address" for when the user is editing an address.

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

  • Posts: 35
  • Thank you received: 1
12 years 2 months ago #61269

Hi Nicolas, Thanks again for your reply.

Would I have to apply these modifications to the hikashop core or can I make template overrides? Could I also use the setUserState to set the country?

Regards

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

  • Posts: 82819
  • Thank you received: 13366
  • MODERATOR
12 years 2 months ago #61274

You can use setUserState and getUserState for the country namekey if you want.
If you do your modifications via the Display->Views as I explained, it will generate overrides automatically.

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

  • Posts: 35
  • Thank you received: 1
12 years 2 months ago #61977

Hello Nicolas,

Where can I find the code for the guest address form at checkout (address and login step)? I'm trying to find the view for that and replace the line that outputs a select box for the country by the fixed country value in simple text.

Thanks

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

  • Posts: 82819
  • Thank you received: 13366
  • MODERATOR
12 years 2 months ago #62053

Why not simply change the country field type from "dropdown" to "text" via the menu Display->Custom fields ?

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

  • Posts: 35
  • Thank you received: 1
12 years 2 months ago #62146

Thanks... nice to see that I can do that, but still, how can I override the output of those fields with my own code?

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

  • Posts: 82819
  • Thank you received: 13366
  • MODERATOR
12 years 2 months ago #62194

Either you have to modify the file administrator/components/com_hikashop/classes/field.php where the fields HTML is generated, or edit the file "custom_fields" of the view "user" via the menu Display->Views and change the call to to field class.

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

  • Posts: 35
  • Thank you received: 1
12 years 2 months ago #62448

Thanks, the custom_fields override works well. I promised myself I'd never "hack the core" again... I'm still running a Joomla 1.0 website because I did that once. It's always preferable to override the output without modifying a hikashop class. So my solution is pretty much set up now:

- a module to switch the country, loaded with the hikashop country zones and defaults to the geolocated country
- the module switches currency and sets the zone once a country is selected
- the custom_fields override takes the zone info, translates that into a country zone_namekey and sets the address country. Then it simply outputs the country with a flag alongside the state selection.

Still have some adjustments here and there but I think it's pretty much solved. Thanks

Attachments:

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

  • Posts: 82819
  • Thank you received: 13366
  • MODERATOR
12 years 2 months ago #62606

Thank you for your feedback :)
Indeed overrides are the way to go !

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

Time to create page: 0.087 seconds
Powered by Kunena Forum