本文整理汇总了PHP中Currency::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::exists方法的具体用法?PHP Currency::exists怎么用?PHP Currency::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency::exists方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Overriding check if currency rate is not empty and if currency with the same iso code already exists.
* If it's true, currency is not added.
*
* @see ObjectModelCore::add()
*/
public function add($autodate = true, $nullValues = false)
{
if ((double) $this->conversion_rate <= 0) {
return false;
}
return Currency::exists($this->iso_code, $this->iso_code_num) ? false : parent::add($autodate, $nullValues);
}
示例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;
}
示例3: execValidation
public function execValidation($cart)
{
global $cookie;
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->active) {
Tools::redirect('index.php?controller=order&step=1');
}
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
$authorized = false;
foreach (Module::getPaymentModules() as $module) {
if ($module['name'] == 'veritranspay') {
$authorized = true;
break;
}
}
if (!$authorized) {
die($this->module->l('This payment method is not available.', 'validation'));
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$usd = Configuration::get('VT_KURS');
$cf = Configuration::get('VT_CONVENIENCE_FEE') * 0.01;
$list_enable_payments = array();
if (Configuration::get('ENABLED_CREDIT_CARD')) {
$list_enable_payments[] = "credit_card";
}
if (Configuration::get('ENABLED_CIMB')) {
$list_enable_payments[] = "cimb_clicks";
}
if (Configuration::get('ENABLED_MANDIRI')) {
$list_enable_payments[] = "mandiri_clickpay";
}
if (Configuration::get('ENABLED_PERMATAVA')) {
$list_enable_payments[] = "bank_transfer";
}
if (Configuration::get('ENABLED_BRIEPAY')) {
$list_enable_payments[] = "bri_epay";
}
if (Configuration::get('ENABLED_TELKOMSEL_CASH')) {
$list_enable_payments[] = "telkomsel_cash";
}
if (Configuration::get('ENABLED_XL_TUNAI')) {
$list_enable_payments[] = "xl_tunai";
}
if (Configuration::get('ENABLED_MANDIRI_BILL')) {
$list_enable_payments[] = "echannel";
}
if (Configuration::get('ENABLED_BBM_MONEY')) {
$list_enable_payments[] = "bbm_money";
}
if (Configuration::get('ENABLED_INDOMARET')) {
$list_enable_payments[] = "cstore";
}
if (Configuration::get('ENABLED_INDOSAT_DOMPETKU')) {
$list_enable_payments[] = "indosat_dompetku";
}
if (Configuration::get('ENABLED_MANDIRI_ECASH')) {
$list_enable_payments[] = "mandiri_ecash";
}
//error_log(print_r($list_enable_payments,TRUE));
$veritrans = new Veritrans_Config();
//SETUP
Veritrans_Config::$serverKey = Configuration::get('VT_SERVER_KEY');
Veritrans_Config::$isProduction = Configuration::get('VT_ENVIRONMENT') == 'production' ? true : false;
$url = Veritrans_Config::getBaseUrl();
if (version_compare(Configuration::get('PS_VERSION_DB'), '1.5') == -1) {
$shipping_cost = $cart->getOrderShippingCost();
} else {
$shipping_cost = $cart->getTotalShippingCost();
}
$currency = new Currency($cookie->id_currency);
$total = $cart->getOrderTotal(true, Cart::BOTH);
$mailVars = array();
$billing_address = new Address($cart->id_address_invoice);
$delivery_address = new Address($cart->id_address_delivery);
if (Configuration::get('VT_3D_SECURE') == 'on' || Configuration::get('VT_3D_SECURE') == 1) {
Veritrans_Config::$is3ds = true;
}
if (Configuration::get('VT_SANITIZED') == 'on' || Configuration::get('VT_SANITIZED') == 1) {
Veritrans_Config::$isSanitized = true;
}
//error_log('sanitized '.Configuration::get('VT_SANITIZED'));
// Billing Address
$params_billing_address = array('first_name' => $billing_address->firstname, 'last_name' => $billing_address->lastname, 'address' => $billing_address->address1, 'city' => $billing_address->city, 'postal_code' => $billing_address->postcode, 'phone' => $this->determineValidPhone($billing_address->phone, $billing_address->phone_mobile), 'country_code' => 'IDN');
if ($cart->isVirtualCart()) {
} else {
if ($cart->id_address_delivery != $cart->id_address_invoice) {
$params_shipping_address = array('first_name' => $delivery_address->firstname, 'last_name' => $delivery_address->lastname, 'address' => $delivery_address->address1, 'city' => $delivery_address->city, 'postal_code' => $delivery_address->postcode, 'phone' => $this->determineValidPhone($delivery_address->phone, $delivery_address->phone_mobile), 'country_code' => 'IDN');
} else {
$params_shipping_address = $params_billing_address;
}
}
$params_customer_details = array('first_name' => $billing_address->firstname, 'last_name' => $billing_address->lastname, 'email' => $customer->email, 'phone' => $this->determineValidPhone($billing_address->phone, $billing_address->phone_mobile), 'billing_address' => $params_billing_address, 'shipping_address' => $params_shipping_address);
$items = $this->addCommodities($cart, $shipping_cost, $usd);
// convert the currency
$cart_currency = new Currency($cart->id_currency);
if ($cart_currency->iso_code != 'IDR') {
// check whether if the IDR is installed or not
if (Currency::exists('IDR', null)) {
//.........这里部分代码省略.........
示例4: _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;
}
示例5: add
/**
* Overriding check if currency with the same iso code already exists.
* If it's true, currency is doesn't added.
*
* @see ObjectModelCore::add()
*/
public function add($autodate = true, $nullValues = false)
{
return Currency::exists($this->iso_code, $this->iso_code_num) ? false : parent::add();
}
示例6: initProcess
/**
* @see AdminController::initProcess()
*/
public function initProcess()
{
if (Tools::isSubmit('SubmitExchangesRates')) {
if ($this->tabAccess['edit'] === '1') {
$this->action = 'exchangeRates';
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
if (Tools::isSubmit('submitAddcurrency') && !Tools::getValue('id_currency') && Currency::exists(Tools::getValue('iso_code'), Tools::getValue('iso_code_num'))) {
$this->errors[] = Tools::displayError('This currency already exists.');
}
if (Tools::isSubmit('submitAddcurrency') && (double) Tools::getValue('conversion_rate') <= 0) {
$this->errors[] = Tools::displayError('The currency conversion rate can not be equal to 0.');
}
parent::initProcess();
}
示例7: hookDisplayPayment
/**
* @return string
*/
public function hookDisplayPayment()
{
if (!Currency::exists('EUR', 0)) {
return '<p class="payment_module" style="color:red;">' . $this->l('Mollie Payment Methods are only available when Euros are activated.') . '</p>';
}
$issuer_setting = $this->getConfigValue('MOLLIE_ISSUERS');
try {
$methods = $this->api->methods->all();
$issuer_list = in_array($issuer_setting, array(self::ISSUERS_ALWAYS_VISIBLE, self::ISSUERS_ON_CLICK)) ? $this->_getIssuerList() : array();
} catch (Mollie_API_Exception $e) {
$methods = array();
$issuer_list = array();
if ($this->getConfigValue('MOLLIE_DEBUG_LOG') == self::DEBUG_LOG_ERRORS) {
Logger::addLog(__METHOD__ . ' said: ' . $e->getMessage(), Mollie::ERROR);
}
if ($this->getConfigValue('MOLLIE_DISPLAY_ERRORS')) {
return '<p class="payment_module" style="color:red;">' . $e->getMessage() . '</p>';
}
}
$this->smarty->assign(array('methods' => $methods, 'issuers' => $issuer_list, 'issuer_setting' => $issuer_setting, 'images' => $this->getConfigValue('MOLLIE_IMAGES'), 'warning' => $this->warning, 'msg_pay_with' => $this->lang['Pay with %s'], 'msg_bankselect' => $this->lang['Select your bank:'], 'module' => $this));
return $this->display(__FILE__, 'mollie_methods.tpl');
}
示例8: checkRequirements
/**
* Check technical requirements to make sure the Stripe's module will work properly
*
* @return array Requirements tests results
*/
public function checkRequirements()
{
$tests = array('result' => true);
$tests['curl'] = array('name' => $this->l('PHP cURL extension must be enabled on your server'), 'result' => is_callable('curl_exec'));
if (Configuration::get('STRIPE_MODE')) {
$tests['ssl'] = array('name' => $this->l('SSL must be enabled on your store (before entering Live mode)'), 'result' => Configuration::get('PS_SSL_ENABLED') || !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off');
}
$tests['currencies'] = array('name' => $this->l('The currency USD or CAD must be enabled on your store'), 'result' => Currency::exists('USD', 0) || Currency::exists('CAD', 0));
$tests['php52'] = array('name' => $this->l('Your server must run PHP 5.2 or greater'), 'result' => version_compare(PHP_VERSION, '5.2.0', '>='));
$tests['configuration'] = array('name' => $this->l('Your must sign-up for Stripe and configure your account settings in the module (publishable key, secret key...etc.)'), 'result' => $this->checkSettings());
if (_PS_VERSION_ < 1.5) {
$tests['backward'] = array('name' => $this->l('You are using the backward compatibility module'), 'result' => $this->backward, 'resolution' => $this->backward_error);
$tmp = Module::getInstanceByName('mobile_theme');
if ($tmp && isset($tmp->version) && !version_compare($tmp->version, '0.3.8', '>=')) {
$tests['mobile_version'] = array('name' => $this->l('You are currently using the default mobile template, the minimum version required is v0.3.8') . ' (v' . $tmp->version . ' ' . $this->l('detected') . ' - <a target="_blank" href="http://addons.prestashop.com/en/mobile-iphone/6165-prestashop-mobile-template.html">' . $this->l('Please Upgrade') . '</a>)', 'result' => version_compare($tmp->version, '0.3.8', '>='));
}
}
foreach ($tests as $k => $test) {
if ($k != 'result' && !$test['result']) {
$tests['result'] = false;
}
}
return $tests;
}
示例9: 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;
}
示例10: initProcess
/**
* @see AdminController::initProcess()
*/
public function initProcess()
{
if (Tools::isSubmit('SubmitExchangesRates')) {
if ($this->access('edit')) {
$this->action = 'exchangeRates';
} else {
$this->errors[] = $this->trans('You do not have permission to edit this.', array(), 'Admin.Notifications.Error');
}
}
if (Tools::isSubmit('submitAddcurrency') && !Tools::getValue('id_currency') && Currency::exists(Tools::getValue('iso_code'))) {
$this->errors[] = $this->trans('This currency already exists.', array(), 'Admin.International.Notification');
}
if (Tools::isSubmit('submitAddcurrency') && (double) Tools::getValue('conversion_rate') <= 0) {
$this->errors[] = $this->trans('The currency conversion rate cannot be equal to 0.', array(), 'Admin.International.Notification');
}
parent::initProcess();
}
示例11: add
/**
* Overriding check if currency rate is not empty and if currency with the same iso code already exists.
* If it's true, currency is not added.
*
* @see ObjectModelCore::add()
*/
public function add($autodate = true, $nullValues = false)
{
if ((double) $this->conversion_rate <= 0) {
return false;
}
$cldrCurrency = $this->cldr->getCurrency($this->iso_code);
$this->name = $cldrCurrency['name'];
return Currency::exists($this->iso_code) ? false : parent::add($autodate, $nullValues);
}