本文整理匯總了PHP中PaymentModule::addCurrencyPermissions方法的典型用法代碼示例。如果您正苦於以下問題:PHP PaymentModule::addCurrencyPermissions方法的具體用法?PHP PaymentModule::addCurrencyPermissions怎麽用?PHP PaymentModule::addCurrencyPermissions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PaymentModule
的用法示例。
在下文中一共展示了PaymentModule::addCurrencyPermissions方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _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;
}
示例2: _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;
}