Kênh 360 Công Nghệ Kênh 360 Công Nghệ

Trang chủ - PrestaShop - Hướng dẫn - Tự cập nhật tỉ giá tiền cho Prestashop

Tự cập nhật tỉ giá tiền cho Prestashop

Chức năng tự động cập nhật tỉ giá các đơn vị tiền tệ Update conversion rates trong Prestashop thực ra sẽ lấy dữ liệu từ file "currencies.xml" được lưu và cập nhật nội dung trên server của Prestashop.

Nội dụng file "http://www.prestashop.com/xml/currencies.xml"

Code:

<?xml="1.0" encoding="UTF-8"?>
<currencies>
<
source iso_code='EUR' />

<
currency iso_code='USD' rate='1.55' />
<
currency iso_code='JPY' rate='167.59' />
<
currency iso_code='VND' rate='26445.00' />
<
currency iso_code='BGN' rate='1.96' />
<
currency iso_code='CZK' rate='24.19' />
<
currency iso_code='DKK' rate='7.46' />
<
currency iso_code='EEK' rate='15.65' />
<
currency iso_code='GBP' rate='0.79' />
<
currency iso_code='HUF' rate='246.34' />
<
currency iso_code='LTL' rate='3.45' />
<
currency iso_code='LVL' rate='0.71' />
<
currency iso_code='PLN' rate='3.38' />
<
currency iso_code='RON' rate='3.66' />
<
currency iso_code='SEK' rate='9.36' />
<
currency iso_code='SKK' rate='30.31' />
<
currency iso_code='CHF' rate='1.62' />
<
currency iso_code='ISK' rate='123.74' />
<
currency iso_code='NOK' rate='8.02' />
<
currency iso_code='HRK' rate='7.24' />
<
currency iso_code='RUB' rate='36.64' />
<
currency iso_code='TRY' rate='1.9' />
<
currency iso_code='AUD' rate='1.65' />
<
currency iso_code='BRL' rate='2.51' />
<
currency iso_code='CAD' rate='1.58' />
<
currency iso_code='CNY' rate='10.67' />
<
currency iso_code='HKD' rate='12.09' />
<
currency iso_code='IDR' rate='14398.25' />
<
currency iso_code='KRW' rate='1579.43' />
<
currency iso_code='MXN' rate='15.94' />
<
currency iso_code='MYR' rate='5.02' />
<
currency iso_code='NZD' rate='2.05' />
<
currency iso_code='PHP' rate='68.2' />
<
currency iso_code='SGD' rate='2.12' />
<
currency iso_code='THB' rate='51.38' />
<
currency iso_code='ZAR' rate='12.41' />

</currencies>

Như các bạn đã thấy thì nguồn dữ liệu để so sánh là đồng EURO. Và không có đồng VND của chúng ta.
Vì vậy chúng ta phải tự thêm đơn vị tiền tệ Việt Nam Đồng vào.
Do đó khi set VND làm mặc định và UPDATE thì tỉ giá của đồng $ với VND là khoảng 1,48.

Để cập nhật tự động tỉ giá của các loại tiền USD, EURO,... so với đồng Việt Nam, ban tham khảo các bước sau:

submitExchangesRates

static public function refreshCurrencies()
{
if (!$feed = @simplexml_load_file('http://www.prestashop.com/xml/currencies.xml'))
return Tools::displayError('Cannot parse feed!');
if (!$defaultCurrency = intval(Configuration::get('PS_CURRENCY_DEFAULT')))
return Tools::displayError('No default currency!');
$isoCodeSource = strval($feed->source['iso_code']);
$currencies = self::getCurrencies(true);
$defaultCurrency = self::refreshCurrenciesGetDefault($feed->list, $isoCodeSource, $defaultCurrency);
foreach ($currencies as $currency)
if ($currency->iso_code != $defaultCurrency->iso_code)
$currency->refreshCurrency($feed->list, $isoCodeSource, $defaultCurrency);
}

Bạn có giải pháp nào tốt hơn không ? Hãy chia sẻ kiến thức của bạn với mọi người.

Còn nữa...



Tin liên quan:
Tin mới hơn:
Tin cũ hơn:

Lần cập nhật cuối ( Chủ nhật, 05 Tháng 7 2009 12:13 )  

Kênh 360 công nghệ

  • Nổi bật
  • Tin mới
  • Game mới
  • PrestaShop Guide
  • PrestaShop

Có thể bạn quan tâm

Download nhiều nhất

11/12
Download PES 2011 - FIFA 11
693
18/12
binkw32 dll
175
18/12
TeamViewerQS
49
English French German Japanese Korean