Geolocation plugin: enforce a certain currency?

  • Posts: 35
  • Thank you received: 3
8 years 11 months ago #250350

-- url of the page with the problem -- : shop.smartgart.com/de/rauchwarnmelder/pr...rene-pope004001.html
-- HikaShop version -- : 2.6.3
-- Joomla version -- : 3.5.1
-- PHP version -- : 5.5.28
-- Browser(s) name and version -- : Chrome XXX
-- Error-message(debug-mod must be tuned on) -- : Google warning for "wrong" currency (Geolocation plugin)

HikaShop + geolocation plugin + default currency
www.hikashop.com/support/documentation/7...n.html#configuration

Question: Possible to link to a page and enforce a specific currency, e. g. EUR?

Not really a bug but a hidden feature question:
For Google Merchants/Shopping, I generate a tab-separated price feed file, e. g. for France:
www.smartgart.com/export/export-prices-google-fr.tsv
Prices are in Euro, and the links go deeply to the product page.

So when a French visitor to visit the page, the product value is displayed in EUR.
But for a Canadian or Indian visitor, the product value is displayed in CAD or INR.

This makes lots of sense, but for Google Shopping, I need to enforce that (independent of visitor location) the price is displayed in a certain currency, i. e. EUR for France. This is so that when a Google tester from non-France, non-Euro clicks, they do not see the "wrong" (their own) currency.

Is there a secret override switch like ?currency=EUR?

If not, I have to code that in, because Google has warned me.

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

  • Posts: 84313
  • Thank you received: 13705
  • MODERATOR
8 years 11 months ago #250433

Hi,

Well, there is no easy parameter like that but it is possible.
For example, with that URL:
shop.smartgart.com/index.php?option=com_...y=XXX&return_url=YYY

where XXX is the id of the currency and YYY the URL you want to display.
But SEO-wise, it's not really nice to have that.
In your case, the best would be a small system plugin which would be loaded on all the pages of the website and get the value of the currency from a URL parameter like you said, and set it in the session like it's done in components/com_hikashop/controllers/currency.php

The following user(s) said Thank You: hactic

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

  • Posts: 35
  • Thank you received: 3
8 years 11 months ago #251003

Thanks Nicolas. Writing a system plugin makes the most sense, however I don't feel proficient enough at the moment.

I tried to quickly hack a function into the components/com_hikashop/controllers/currency.php (snippet below),
however I do not understand how to register it with the lifecycle of the runtime environment.

The idea is that I pass a parameter key/value like &cur=2, and the currency gets set to that currency_id.
Howevere, update() is only called for the update POST of the currency module,
whilst my initial load is the GET from a Google Shopping shopping page.

I checked the .xml's for configuring that but cannot figure it out yet.

best regards

Klaus

	function get() {
		$currency=JRequest::getInt('cur',0,'get'); // override for/from Google Shopping
		// or: $currency = $_GET['cur'];
		if(strlen($currency) > 3) $cur = 1; // simple filtering against injections
		if(!empty($currency)){
			$app = JFactory::getApplication();
			$app->setUserState( HIKASHOP_COMPONENT.'.currency_id', $currency );
		}
	}

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

  • Posts: 84313
  • Thank you received: 13705
  • MODERATOR
8 years 11 months ago #251037

Hi,

The problem lies in these two sentences:

I do not understand how to register it with the lifecycle of the runtime environment.

Writing a system plugin makes the most sense, however I don't feel proficient enough at the moment.

To "register it with the lifecycle of the runtime environment", you need to write a system plugin. And that's why I recommended that.
Writing a plugin is not difficult if you know know a bit on programming. Just follow the Joomla documentation on how to write a plugin:
docs.joomla.org/Portal:Plugin_Development
And implement a trigger (like the "onAfterRoute" trigger) where you would put the code that you have in your get() function (and replace HIKASHOP_COMPONENT by "com_hikashop" ).

The following user(s) said Thank You: hactic

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

Time to create page: 0.062 seconds
Powered by Kunena Forum