Jump to content

mattf10

Members
  • Posts

    4
  • Joined

  • Last visited

Profile Information

  • Location
    France
  • Activity
    Web development agency

mattf10's Achievements

Newbie

Newbie (1/14)

2

Reputation

  1. Edit: I see someone beat me to it! Great minds think alike I guess. In the end, I got tired of waiting and fixed the problem myself. I'm sharing the code here in case anyone finds it useful. The code below works for me, but I make no guarantees. Use it at your own risk. I'm using rates from the European Central Bank ( http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml ). It doesn't contain as many rates as the original Prestashop version, but it has enough to suit my purposes. If you'd like to use this, create a file called "Currency.php" and place it in the "/override/classes/" directory. If you use "cron_currency_update", it will call the method in this file instead. class Currency extends CurrencyCore { /** * Refresh the currency exchange rate * The XML file define exchange rate for each from a default currency ($isoCodeSource). * * @param SimpleXMLElement $data XML content which contains all the exchange rates * @param string $isoCodeSource The default currency used in the XML file * @param Currency $defaultCurrency The default currency object */ public function refreshCurrency($data, $isoCodeSource, $defaultCurrency) { // fetch the exchange rate of the default currency $exchange_rate = 1; $tmp = $this->conversion_rate; if ($defaultCurrency->iso_code != $isoCodeSource) { foreach ($data->Cube as $currency) { if ($currency['currency'] == $defaultCurrency->iso_code) { $exchange_rate = round((float)$currency['rate'], 6); break; } } } if ($defaultCurrency->iso_code == $this->iso_code) { $this->conversion_rate = 1; } else { if ($this->iso_code == $isoCodeSource) { $rate = 1; } else { foreach ($data->Cube as $obj) { if ($this->iso_code == strval($obj['currency'])) { $rate = (float)$obj['rate']; break; } } } if (isset($rate)) { $this->conversion_rate = round($rate / $exchange_rate, 6); } } if ($tmp != $this->conversion_rate) { $this->update(); } } public static function refreshCurrencies() { // Prestashop no longer provide currency rates from their API // get them from the European Central Bank if (!$feed = Tools::simplexml_load_file('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml')) { return Tools::displayError('Cannot parse feed.'); } // Default feed currency - this is always EUR and not provided in the feed: hardcode it $isoCodeSource = 'EUR'; // returns the shop default - we want this to be EUR //if (!$default_currency = Currency::getDefaultCurrency()) { $default_currency_id = Currency::getIdByIsoCode($isoCodeSource); if (!$default_currency = Currency::getCurrency($default_currency_id)) { return Tools::displayError('No default currency'); } $currencies = Currency::getCurrencies(true, false, true); foreach ($currencies as $currency) { /** @var Currency $currency */ if ($currency->id != $default_currency->id) { // in our xml, the rates are nested in two "Cube" elements if ( isset($feed->Cube, $feed->Cube->Cube) ) $currency->refreshCurrency($feed->Cube->Cube, $isoCodeSource, $default_currency); } } } }
  2. I use the Prestashop web service to update my currency rates. I notice that the rates have not changed in over a week. Yes, I realise that the service is provided "as is", but the system does not have a way to download rates from other sources. The xml file with the rates comes from here: http://api.prestashop.com/xml/currencies.xml. Can someone please investigate why this file is not being updated?
  3. I figured it out. The new stores use different currencies than the default store. I had to enable the currencies of the new shops, and the payment methods now correctly appear at checkout.
  4. I recently upgraded to 1.6.1.1 from 1.5 and enabled multistore. Problem: For the new stores, certain payment methods (bankwire, check) are not appearing at checkout. These modules are authorised for specific customer groups only. For the original (default) shop, the payment methods appear correctly for customers in the specific groups. When I edit the customer groups, I see that the two payment modules are enabled for these customer groups. I have also checked the database, and confirm that the access is correctly set for each customer group/module/shop combo. Any ideas why these payment methods are not showing for the new shops?
×
×
  • Create New...