Jump to content

How to add currency to url


Recommended Posts

Hello, I have been sending product feed files to Google Merchant for several countries using each countries currency which are different to my default currency.

 

Google have now rejected my feeds as the price they see on on my website is different to that sent in the feeds. Google only sees my default currency prices.

 

Is there a solution other than using the multi store function?

 

Has anyone been able to add the currency to the URL?

 

Cheers, Steve

Link to comment
Share on other sites

No solution?

 

It appears that the very popular Google Merchant Centre module is of no value as Google will not accept the feeds it generates in any currency other than the default which in my case is NZD!

Link to comment
Share on other sites

  • 2 months later...

For PS 1.5 add a file Tools.php in /overrides/classes/ with this code :

Then delete the file class_index.php in /cache (it will be re-generated automatically)

 

After you will be able to force the currency by the id

For example :

www.myshop.com/en/?c=3

(currency id 3)

 

<?php

class Tools extends ToolsCore
{

public static function setCurrency($cookie)
{
 if (Tools::isSubmit('SubmitCurrency'))
  if (isset($_POST['id_currency']) && is_numeric($_POST['id_currency']))
  {
$currency = Currency::getCurrencyInstance($_POST['id_currency']);
if (is_object($currency) && $currency->id && !$currency->deleted && $currency->isAssociatedToShop())
 $cookie->id_currency = (int)$currency->id;
  }
 // Get Currency from URL (start)
 if (isset($_GET['c']) AND is_numeric($_GET['c']))
 {
  $currency = Currency::getCurrencyInstance((int)($_GET['c']));
  if (is_object($currency) AND $currency->id AND !$currency->deleted)
$cookie->id_currency = (int)($currency->id);
 }
// END
 if ((int)$cookie->id_currency)
 {
  $currency = Currency::getCurrencyInstance((int)$cookie->id_currency);
  if (is_object($currency) && (int)$currency->id && (int)$currency->deleted != 1 && $currency->active)
if ($currency->isAssociatedToShop())
 return $currency;
else
{
 // get currency from context
 $currency = Shop::getEntityIds('currency', Context::getContext()->shop->id);
 $cookie->id_currency = $currency[0]['id_currency'];
 return Currency::getCurrencyInstance((int)$cookie->id_currency);
}
 }
 $currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
 if (is_object($currency) && $currency->id)
  $cookie->id_currency = (int)$currency->id;
 return $currency;
}


}

Edited by dric83 (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Not sure if this was answered on some other forum, but in case it is not

 

We are on PrestaShop 1.6.12

It should allow you to do it with SubmitCurrency=anything&id_currency=1

 

yoururl.com/page.html?SubmitCurrency=yes&id_currency=1

yoururl.com/page.html?SubmitCurrency=yes&id_currency=2

 

id_currency should be the currency IDs in the Currency setup on the admin

 

Note: id_currency is by default blocked in prestaShop's robots.txt file. I am not an expert on Google Merchant, but if their crawler/checker is abiding by the robots.txt you will need to Allow id_currency in the robots.txt file

Edited by lecairelinens (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...