本文整理汇总了PHP中Currency::refreshCurrencies方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::refreshCurrencies方法的具体用法?PHP Currency::refreshCurrencies怎么用?PHP Currency::refreshCurrencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency::refreshCurrencies方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hookDisplayFooter
public function hookDisplayFooter()
{
if ($this->update_source != 'auto' or (int) $this->last_update + $this->task_time > time()) {
return;
}
if ($this->update_rates == 'yes') {
Currency::refreshCurrencies();
}
if ($this->update_prices == 'yes') {
$this->UpdateAll();
}
}
示例2: postProcess
public function postProcess()
{
global $currentIndex;
if (isset($_GET['delete' . $this->table])) {
if ($this->tabAccess['delete'] === '1') {
if (Validate::isLoadedObject($object = $this->loadObject())) {
if ($object->id == Configuration::get('PS_CURRENCY_DEFAULT')) {
$this->_errors[] = $this->l('You can\'t delete the default currency');
} elseif ($object->delete()) {
Tools::redirectAdmin($currentIndex . '&conf=1' . '&token=' . $this->token);
} else {
$this->_errors[] = Tools::displayError('an error occurred during deletion');
}
} else {
$this->_errors[] = Tools::displayError('an error occurred while deleting object') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
} elseif (Tools::getValue('submitOptions' . $this->table)) {
foreach ($this->_fieldsOptions as $key => $field) {
Configuration::updateValue($key, $field['cast'](Tools::getValue($key)));
if ($key == 'PS_CURRENCY_DEFAULT') {
$currency = new Currency($field['cast'](Tools::getValue($key)));
$currency->conversion_rate = 1;
$currency->update();
}
}
Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token);
} elseif (Tools::isSubmit('submitExchangesRates')) {
if (!($this->_errors[] = Currency::refreshCurrencies())) {
Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token);
}
} else {
parent::postProcess();
}
}
示例3: postProcess
public function postProcess()
{
global $currentIndex;
if (isset($_GET['delete' . $this->table])) {
if ($this->tabAccess['delete'] === '1') {
if (Validate::isLoadedObject($object = $this->loadObject())) {
if ($object->id == Configuration::get('PS_CURRENCY_DEFAULT')) {
$this->_errors[] = $this->l('You cannot delete the default currency');
} elseif ($object->delete()) {
Tools::redirectAdmin($currentIndex . '&conf=1' . '&token=' . $this->token);
} else {
$this->_errors[] = Tools::displayError('An error occurred during deletion.');
}
} else {
$this->_errors[] = Tools::displayError('An error occurred while deleting object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
} elseif ((isset($_GET['status' . $this->table]) or isset($_GET['status'])) and Tools::getValue($this->identifier)) {
if ($this->tabAccess['edit'] === '1') {
if (Validate::isLoadedObject($object = $this->loadObject())) {
if ($object->active and $object->id == Configuration::get('PS_CURRENCY_DEFAULT')) {
$this->_errors[] = $this->l('You cannot disable the default currency');
} elseif ($object->toggleStatus()) {
Tools::redirectAdmin($currentIndex . '&conf=5' . (($id_category = (int) Tools::getValue('id_category') and Tools::getValue('id_product')) ? '&id_category=' . $id_category : '') . '&token=' . $this->token);
} else {
$this->_errors[] = Tools::displayError('An error occurred while updating status.');
}
} else {
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
} elseif (Tools::getValue('submitOptions' . $this->table)) {
foreach ($this->_fieldsOptions as $key => $field) {
Configuration::updateValue($key, $field['cast'](Tools::getValue($key)));
if ($key == 'PS_CURRENCY_DEFAULT') {
Currency::refreshCurrencies();
}
}
Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token);
} elseif (Tools::isSubmit('submitExchangesRates')) {
if (!($this->_errors[] = Currency::refreshCurrencies())) {
Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token);
}
} else {
parent::postProcess();
}
}
示例4: _installCurrencies
/**
* @param SimpleXMLElement $xml
* @param bool $install_mode
* @return bool
* @throws PrestaShopException
*/
protected function _installCurrencies($xml, $install_mode = false)
{
if (isset($xml->currencies->currency)) {
foreach ($xml->currencies->currency as $data) {
/** @var SimpleXMLElement $data */
$attributes = $data->attributes();
if (Currency::exists($attributes['iso_code'], (int) $attributes['iso_code_num'])) {
continue;
}
$currency = new Currency();
$currency->name = (string) $attributes['name'];
$currency->iso_code = (string) $attributes['iso_code'];
$currency->iso_code_num = (int) $attributes['iso_code_num'];
$currency->sign = (string) $attributes['sign'];
$currency->blank = (int) $attributes['blank'];
$currency->conversion_rate = 1;
// This value will be updated if the store is online
$currency->format = (int) $attributes['format'];
$currency->decimals = (int) $attributes['decimals'];
$currency->active = true;
if (!$currency->validateFields()) {
$this->_errors[] = Tools::displayError('Invalid currency properties.');
return false;
}
if (!Currency::exists($currency->iso_code, $currency->iso_code_num)) {
if (!$currency->add()) {
$this->_errors[] = Tools::displayError('An error occurred while importing the currency: ') . strval($attributes['name']);
return false;
}
PaymentModule::addCurrencyPermissions($currency->id);
}
}
if (($error = Currency::refreshCurrencies()) !== null) {
$this->_errors[] = $error;
}
if (!count($this->_errors) && $install_mode && isset($attributes['iso_code']) && count($xml->currencies->currency) == 1) {
$this->iso_currency = $attributes['iso_code'];
}
}
return true;
}
示例5: _installCurrencies
protected function _installCurrencies($xml, $install_mode = false)
{
if (isset($xml->currencies->currency)) {
if (!($feed = Tools::simplexml_load_file('http://www.prestashop.com/xml/currencies.xml')) and !($feed = @simplexml_load_file(dirname(__FILE__) . '/../localization/currencies.xml'))) {
$this->_errors[] = Tools::displayError('Cannot parse the currencies XML feed.');
return false;
}
foreach ($xml->currencies->currency as $data) {
$attributes = $data->attributes();
if (Currency::exists($attributes['iso_code'])) {
continue;
}
$currency = new Currency();
$currency->name = strval($attributes['name']);
$currency->iso_code = strval($attributes['iso_code']);
$currency->iso_code_num = (int) $attributes['iso_code_num'];
$currency->sign = strval($attributes['sign']);
$currency->blank = (int) $attributes['blank'];
$currency->conversion_rate = 1;
// This value will be updated if the store is online
$currency->format = (int) $attributes['format'];
$currency->decimals = (int) $attributes['decimals'];
$currency->active = $install_mode;
if (!$currency->validateFields()) {
$this->_errors[] = Tools::displayError('Invalid currency properties.');
return false;
}
if (!Currency::exists($currency->iso_code)) {
if (!$currency->add()) {
$this->_errors[] = Tools::displayError('An error occurred while importing the currency: ') . strval($attributes['name']);
return false;
}
PaymentModule::addCurrencyPermissions($currency->id);
}
}
Currency::refreshCurrencies();
if (!sizeof($this->_errors) and $install_mode and isset($attributes['iso_code']) and sizeof($xml->currencies->currency) == 1) {
$this->iso_currency = $attributes['iso_code'];
}
}
return true;
}
示例6: define
<?php
/*
* 2015-2016 DOGS
* @author J.Podracky, L.Fisher
* @copyright 2015-2016 F2FCREATIVE
*/
if (!defined('_PS_ADMIN_DIR_')) {
define('_PS_ADMIN_DIR_', getcwd());
}
include _PS_ADMIN_DIR_ . '/../config/config.inc.php';
if (isset($_GET['secure_key'])) {
$secureKey = md5(_COOKIE_KEY_ . Configuration::get('PS_SHOP_NAME'));
if (!empty($secureKey) && $secureKey === $_GET['secure_key']) {
$shop_ids = Shop::getCompleteListOfShopsID();
foreach ($shop_ids as $shop_id) {
Shop::setContext(Shop::CONTEXT_SHOP, (int) $shop_id);
Currency::refreshCurrencies();
}
}
}
示例7: updateOptionPsCurrencyDefault
public function updateOptionPsCurrencyDefault($value)
{
if ($value == Configuration::get('PS_CURRENCY_DEFAULT')) {
return;
}
Configuration::updateValue('PS_CURRENCY_DEFAULT', $value);
/* Set conversion rate of default currency to 1 */
ObjectModel::updateMultishopTable('Currency', array('conversion_rate' => 1), 'a.id_currency');
$tmp_context = Shop::getContext();
if ($tmp_context == Shop::CONTEXT_GROUP) {
$tmp_shop = Shop::getContextShopGroupID();
} else {
$tmp_shop = (int) Shop::getContextShopID();
}
foreach (Shop::getContextListShopID() as $id_shop) {
Shop::setContext(Shop::CONTEXT_SHOP, (int) $id_shop);
Currency::refreshCurrencies();
}
Shop::setContext($tmp_context, $tmp_shop);
}
示例8: processExchangeRates
/**
* Update currency exchange rates
*/
public function processExchangeRates()
{
if (!($this->errors = Currency::refreshCurrencies())) {
Tools::redirectAdmin(self::$currentIndex . '&conf=6&token=' . $this->token);
}
}
示例9: updateOptionPsCurrencyDefault
public function updateOptionPsCurrencyDefault($value)
{
Configuration::updateValue('PS_CURRENCY_DEFAULT', $value);
/* Set conversion rate of default currency to 1 */
ObjectModel::updateMultishopTable('Currency', array('conversion_rate' => 1), 'a.id_currency');
Currency::refreshCurrencies();
}
示例10: updateCurrencies
public function updateCurrencies()
{
$date = Db::getInstance()->getValue('SELECT `last_update` FROM `' . _DB_PREFIX_ . 'gointerpay_cache_currency`');
if ($date == null) {
Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'gointerpay_cache_currency` (`last_update`) VALUES (NOW())');
Currency::refreshCurrencies();
} else {
$hours = floor(abs(strtotime($date) - strtotime('now')) / 3600);
$expiry = Db::getInstance()->getValue('SELECT c.expiry FROM ' . _DB_PREFIX_ . 'currency c WHERE c.iso_code =\'' . $this->context->cookie->interpay_currency_code . '\' AND deleted = 0');
if ($hours > 1 || strtotime($expiry) < strtotime('now')) {
Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'gointerpay_cache_currency` SET `last_update` = NOW()');
Currency::refreshCurrencies();
}
}
}
示例11: install
public function install()
{
include dirname(__FILE__) . '/sql-install.php';
foreach ($sql as $s) {
if (!Db::getInstance()->Execute($s)) {
return false;
}
}
if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('adminOrder') || !$this->registerHook('paymentReturn') || !$this->registerHook('orderConfirmation')) {
return false;
}
$this->registerHook('displayPayment');
$this->registerHook('rightColumn');
$this->registerHook('extraRight');
$this->registerHook('header');
if (!Configuration::get('KLARNA_PAYMENT_ACCEPTED')) {
Configuration::updateValue('KLARNA_PAYMENT_ACCEPTED', $this->addState('Klarna: Payment accepted', '#DDEEFF'));
}
if (!Configuration::get('KLARNA_PAYMENT_PENDING')) {
Configuration::updateValue('KLARNA_PAYMENT_PENDING', $this->addState('Klarna : payment in pending verification', '#DDEEFF'));
}
/*auto install currencies*/
$currencies = array('Euro' => array('iso_code' => 'EUR', 'iso_code_num' => 978, 'symbole' => '€', 'format' => 2), 'Danish Krone' => array('iso_code' => 'DKK', 'iso_code_num' => 208, 'symbole' => 'DAN kr.', 'format' => 2), 'krone' => array('iso_code' => 'NOK', 'iso_code_num' => 578, 'symbole' => 'NOK kr', 'format' => 2), 'Krona' => array('iso_code' => 'SEK', 'iso_code_num' => 752, 'symbole' => 'SEK kr', 'format' => 2));
$languages = array('Swedish' => array('iso_code' => 'se', 'language_code' => 'sv', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'sweden.png'), 'Deutsch' => array('iso_code' => 'de', 'language_code' => 'de', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'germany.png'), 'Dutch' => array('iso_code' => 'nl', 'language_code' => 'nl', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'netherlands.png'), 'Finnish' => array('iso_code' => 'fi', 'language_code' => 'fi', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'finland.jpg'), 'Norwegian' => array('iso_code' => 'no', 'language_code' => 'no', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'norway.png'), 'Danish' => array('iso_code' => 'da', 'language_code' => 'da', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'denmark.png'));
foreach ($currencies as $key => $val) {
if (_PS_VERSION_ >= 1.5) {
$exists = Currency::exists($val['iso_code_num'], $val['iso_code_num']);
} else {
$exists = Currency::exists($val['iso_code_num']);
}
if (!$exists) {
$currency = new Currency();
$currency->name = $key;
$currency->iso_code = $val['iso_code'];
$currency->iso_code_num = $val['iso_code_num'];
$currency->sign = $val['symbole'];
$currency->conversion_rate = 1;
$currency->format = $val['format'];
$currency->decimals = 1;
$currency->active = true;
$currency->add();
}
}
Currency::refreshCurrencies();
$version = str_replace('.', '', _PS_VERSION_);
$version = substr($version, 0, 2);
foreach ($languages as $key => $val) {
$pack = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . $val['language_code'] . '.xml');
if ($pack || ($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . $val['language_code'] . '.xml'))) {
$localizationPack = new LocalizationPack();
$localizationPack->loadLocalisationPack($pack, array('taxes', 'languages'));
}
if (!Language::getIdByIso($val['language_code'])) {
if (_PS_VERSION_ >= 1.5) {
Language::checkAndAddLanguage($val['language_code']);
} else {
$lang = new Language();
$lang->name = $key;
$lang->iso_code = $val['iso_code'];
$lang->language_code = $val['language_code'];
$lang->date_format_lite = $val['date_format_lite'];
$lang->date_format_full = $val['date_format_full'];
$lang->add();
$insert_id = (int) $lang->id;
$pack = Tools::file_get_contents('http://www.prestashop.com/download/localization/' . $val['iso_code'] . '.xml');
$lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . _PS_VERSION_ . '&iso_lang=' . $val['iso_code']));
if ($lang_pack) {
$flag = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/flags/jpeg/' . $val['iso_code'] . '.jpg');
if ($flag != null && !preg_match('/<body>/', $flag)) {
$file = fopen(dirname(__FILE__) . '/../../img/l/' . $insert_id . '.jpg', 'w');
if ($file) {
fwrite($file, $flag);
fclose($file);
}
}
}
}
}
}
foreach ($this->countries as $key => $val) {
$country = new Country(Country::getByIso($key));
$country->active = true;
$country->update();
}
return true;
}
示例12: updateOptionPsCurrencyDefault
public function updateOptionPsCurrencyDefault($value)
{
Configuration::updateValue('PS_CURRENCY_DEFAULT', $value);
Currency::refreshCurrencies();
}