当前位置: 首页>>代码示例>>PHP>>正文


PHP Currency::add方法代码示例

本文整理汇总了PHP中Currency::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::add方法的具体用法?PHP Currency::add怎么用?PHP Currency::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Currency的用法示例。


在下文中一共展示了Currency::add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _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;
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:42,代码来源:LocalizationPack.php

示例2: _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;
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:47,代码来源:LocalizationPack.php

示例3: storeCurrencies

 /**
  * Stores the Currencies as present in the POST request
  *
  * See {@see Currency::delete()},
  * {@see Currency::add()}, and
  * {@see Currency::update()}.
  */
 static function storeCurrencies()
 {
     //DBG::log("start of storeCurrencies: ".self::$success.", changed: ".self::$changed);
     $result = Currency::delete();
     if (isset($result)) {
         self::$changed = true;
         self::$success &= $result;
     }
     //DBG::log("after delete: ".self::$success.", changed: ".self::$changed);
     $result = Currency::add();
     if (isset($result)) {
         self::$changed = true;
         self::$success &= $result;
     }
     //DBG::log("after add: ".self::$success.", changed: ".self::$changed);
     $result = Currency::update();
     if (isset($result)) {
         self::$changed = true;
         self::$success &= $result;
     }
     //DBG::log("after update: ".self::$success.", changed: ".self::$changed);
     if (self::$changed) {
         // Remember to reinit the Currencies, or the User
         // won't see changes instantly
         Currency::reset();
     }
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:34,代码来源:ShopSettings.class.php

示例4: Currency

<?php

if (isset($_POST['sveCurrency']) && Tools::getRequest('sveCurrency') == 'add') {
    $currency = new Currency();
    $currency->copyFromPost();
    $currency->add();
    if (is_array($currency->_errors) and count($currency->_errors) > 0) {
        $errors = $currency->_errors;
    } else {
        $_GET['id'] = $currency->id;
        echo '<div class="conf">创建对象成功</div>';
    }
}
if (isset($_GET['id'])) {
    $id = (int) $_GET['id'];
    $obj = new Currency($id);
}
if (isset($_POST['sveCurrency']) && Tools::getRequest('sveCurrency') == 'edit') {
    if (Validate::isLoadedObject($obj)) {
        $obj->copyFromPost();
        $obj->update();
    }
    if (is_array($obj->_errors) and count($obj->_errors) > 0) {
        $errors = $obj->_errors;
    } else {
        echo '<div class="conf">更新对象成功</div>';
    }
}
/** 输出错误信息 */
if (isset($errors)) {
    UIAdminAlerts::MError($errors);
开发者ID:yiuked,项目名称:tmcart,代码行数:31,代码来源:currency_edit.php

示例5: _addCurrencies

    private function _addCurrencies()
    {
        $currencies = array('AUD' => array('name' => $this->l('Australian Dollar'), 'iso_code_num' => 36, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'CAD' => array('name' => $this->l('Canadian Dollar'), 'iso_code_num' => 124, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'DKK' => array('name' => $this->l('Danish Krone'), 'iso_code_num' => 208, 'sign' => 'kr', 'blank' => true, 'format' => 1, 'decimals' => 2), 'EUR' => array('name' => $this->l('Euro'), 'iso_code_num' => 978, 'sign' => '€', 'blank' => true, 'format' => 2, 'decimals' => 2), 'GBP' => array('name' => $this->l('Pound'), 'iso_code_num' => 826, 'sign' => '£', 'blank' => true, 'format' => 1, 'decimals' => 2), 'JPY' => array('name' => $this->l('Japanese Yen'), 'iso_code_num' => 392, 'sign' => '¥', 'blank' => true, 'format' => 1, 'decimals' => 0), 'NOK' => array('name' => $this->l('Norwegian Krone'), 'iso_code_num' => 578, 'sign' => 'kr', 'blank' => true, 'format' => 1, 'decimals' => 2), 'NZD' => array('name' => $this->l('New Zealand Dollar'), 'iso_code_num' => 554, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'SEK' => array('name' => $this->l('Swedish Krona'), 'iso_code_num' => 752, 'sign' => 'kr', 'blank' => true, 'format' => 1, 'decimals' => 2), 'USD' => array('name' => $this->l('US Dollar'), 'iso_code_num' => 840, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'AED' => array('name' => $this->l('UA Emirates Dirham'), 'iso_code_num' => 784, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'BRL' => array('name' => $this->l('Brazil Real'), 'iso_code_num' => 986, 'sign' => 'R$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'ARS' => array('name' => $this->l('Argentina Peso'), 'iso_code_num' => 32, 'sign' => '$a', 'blank' => true, 'format' => 1, 'decimals' => 2), 'CHF' => array('name' => $this->l('Swiss Franc'), 'iso_code_num' => 756, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'CLP' => array('name' => $this->l('Chile Peso'), 'iso_code_num' => 152, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'CNY' => array('name' => $this->l('China Yuan Renminbi'), 'iso_code_num' => 156, 'sign' => '元', 'blank' => true, 'format' => 1, 'decimals' => 2), 'HKD' => array('name' => $this->l('Hong Kong Dollar'), 'iso_code_num' => 344, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'HUF' => array('name' => $this->l('Hungary Forint'), 'iso_code_num' => 348, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'ILS' => array('name' => $this->l('Israel Shekel'), 'iso_code_num' => 376, 'sign' => '₪', 'blank' => true, 'format' => 1, 'decimals' => 2), 'INR' => array('name' => $this->l('Indian Rupee'), 'iso_code_num' => 356, 'sign' => 'Rs', 'blank' => true, 'format' => 1, 'decimals' => 2), 'KWD' => array('name' => $this->l('Kuwait Dinar'), 'iso_code_num' => 414, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'MYR' => array('name' => $this->l('Malasya Ringgit'), 'iso_code_num' => 458, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'RUB' => array('name' => $this->l('Russia Ruble'), 'iso_code_num' => 643, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'SGD' => array('name' => $this->l('Singapure Dollar'), 'iso_code_num' => 702, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'THB' => array('name' => $this->l('Thailand Baht'), 'iso_code_num' => 764, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'TWD' => array('name' => $this->l('Taiwan New Dollar'), 'iso_code_num' => 901, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'MXN' => array('name' => $this->l('Mexican Peso'), 'iso_code_num' => 484, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2), 'CZK' => array('name' => $this->l('Czech Koruna'), 'iso_code_num' => 203, 'sign' => 'Kr', 'blank' => true, 'format' => 1, 'decimals' => 2), 'PHP' => array('name' => $this->l('Philipine Peso'), 'iso_code_num' => 608, 'sign' => '₱', 'blank' => true, 'format' => 1, 'decimals' => 2), 'PLN' => array('name' => $this->l('Polish Zloty'), 'iso_code_num' => 985, 'sign' => '$', 'blank' => true, 'format' => 1, 'decimals' => 2));
        $iso_codes = '';
        foreach ($currencies as $k => $currency) {
            $iso_codes .= '"' . pSQL($k) . '",';
        }
        $iso_codes = rtrim($iso_codes, ',');
        $current_currencies = Db::getInstance()->ExecuteS('
		SELECT c.id_currency, c.iso_code
		FROM ' . _DB_PREFIX_ . 'currency c
		WHERE c.iso_code IN (' . $iso_codes . ') AND deleted = 0');
        $currencies_list = array();
        foreach ($current_currencies as $currency) {
            $currencies_list[] = $currency['iso_code'];
        }
        $currencies_to_add = array_diff(array_keys($currencies), $currencies_list);
        foreach ($currencies_to_add as $currency_to_add) {
            $currency = new Currency();
            $currency->iso_code = $currency_to_add;
            $currency->name = $currencies[$currency_to_add]['name'];
            $currency->active = 1;
            $currency->deleted = 0;
            $currency->conversion_rate = 1;
            $currency->iso_code_num = $currencies[$currency_to_add]['iso_code_num'];
            $currency->sign = $currencies[$currency_to_add]['sign'];
            $currency->blank = $currencies[$currency_to_add]['blank'];
            $currency->decimals = $currencies[$currency_to_add]['decimals'] ? 1 : 0;
            $currency->format = $currencies[$currency_to_add]['format'];
            $currency->add();
        }
        $current_currencies = Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'currency SET active = 1 WHERE iso_code IN (' . $iso_codes . ')');
        Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'currency SET name = \'US Dollar\' WHERE name = \'Dollar\'');
    }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:34,代码来源:gointerpay.php

示例6: 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;
 }
开发者ID:juniorhq88,项目名称:PrestaShop-modules,代码行数:86,代码来源:klarnaprestashop.php

示例7: importCurrencies

 protected function importCurrencies()
 {
     $this->truncateTables(array('currency', 'currency_shop'));
     $handle = $this->openCsvFile('currencies.csv');
     for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, ';'); $current_line++) {
         $res = false;
         $fields = $this->filterFields('Currency', $this->currencies_fields, $line);
         if (!isset($fields['id'])) {
             $currency = new Currency($line[0]);
             $currency->id = $line[0];
         } else {
             $currency = new Currency($fields['id']);
         }
         foreach ($fields as $key => $field) {
             $currency->{$key} = $field;
         }
         $currency->force_id = true;
         if (!$res) {
             $res = $currency->add();
         }
     }
     $this->closeCsvFile($handle);
     return true;
 }
开发者ID:evgrishin,项目名称:se1614,代码行数:24,代码来源:AdminSampleDataInstallImport.php


注:本文中的Currency::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。