• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP eZCurrencyData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testMultipleCallsToCalculatedPrice

 /**
  * Test scenario for issue #13712: Multiprice datatype shows wrong price after multiple calls in template
  *
  * Test Outline
  * ------------
  * 1. Create a euro currency
  * 2. Create a VAT type of 10 %
  * 3. Create a content class with an attribute of the datatype ezmultiprice
  * 4. Create a content object of this content class and set a custom price ex. VAT with the VAT type of 10% that we created
  * 5. Subsequently retrieve the attribute 'inc_vat_price_list'
  *
  * @result: the returned eZMultiPriceData instances differ on each call, their values are increased each time with VAT
  * @expected: the returned eZMultiPriceData instances are equal
  * @link http://issues.ez.no/13712
  * @group issue_13712
  */
 public function testMultipleCallsToCalculatedPrice()
 {
     $currencyCode = 'EUR';
     // create currency
     $currencyParams = array('code' => $currencyCode, 'symbol' => false, 'locale' => 'eng-GB', 'custom_rate_value' => 0, 'rate_factor' => 1);
     $currency = eZCurrencyData::create($currencyCode, '€', 'eng-GB', 0, 0, 1);
     $currency->store();
     $currencyID = $currency->attribute('id');
     $this->assertInternalType('integer', $currencyID);
     // create VAT type
     $row = array('name' => 'Test', 'percentage' => 10.0);
     $vatType = new eZVatType($row);
     $vatType->store();
     $vatTypeID = $vatType->attribute('id');
     $this->assertInternalType('integer', $vatTypeID);
     $class = eZContentClass::create(false, array('name' => 'eZMultiPrice::testMultipleCallsToCalculatedPrice', 'identifier' => 'ezmultiprice_test'));
     $class->store();
     $classID = $class->attribute('id');
     $this->assertInternalType('integer', $classID);
     $attributes = $class->fetchAttributes();
     // add class attributes
     $newAttribute = eZContentClassAttribute::create($classID, 'ezmultiprice', array('name' => 'Test', 'identifier' => 'test'));
     $dataType = $newAttribute->dataType();
     $dataType->initializeClassAttribute($newAttribute);
     $newAttribute->setAttribute(eZMultiPriceType::DEFAULT_CURRENCY_CODE_FIELD, $currencyCode);
     $newAttribute->setAttribute(eZMultiPriceType::VAT_ID_FIELD, $vatTypeID);
     $newAttribute->store();
     $attributes[] = $newAttribute;
     $class->storeDefined($attributes);
     $contentObject = $class->instantiate();
     $version = $contentObject->currentVersion();
     $dataMap = $version->dataMap();
     $multiPrice = $dataMap['test']->content();
     $multiPrice->setAttribute('selected_vat_type', $vatTypeID);
     $multiPrice->setAttribute('is_vat_included', eZMultiPriceType::EXCLUDED_VAT);
     $multiPrice->setCustomPrice($currencyCode, 100);
     $multiPrice->updateAutoPriceList();
     $dataMap['test']->setContent($multiPrice);
     $dataMap['test']->setAttribute('data_text', $vatTypeID . ',' . eZMultiPriceType::EXCLUDED_VAT);
     $dataMap['test']->store();
     // test values
     $firstIncVatPriceList = $multiPrice->attribute('inc_vat_price_list');
     $this->assertArrayHasKey('EUR', $firstIncVatPriceList);
     $firstCallValue = $firstIncVatPriceList['EUR']->attribute('value');
     $secondIncVatPriceList = $multiPrice->attribute('inc_vat_price_list');
     $this->assertArrayHasKey('EUR', $secondIncVatPriceList);
     $secondCallValue = $secondIncVatPriceList['EUR']->attribute('value');
     $this->assertEquals($firstCallValue, $secondCallValue);
     $thirdIncVatPriceList = $multiPrice->attribute('inc_vat_price_list');
     $this->assertArrayHasKey('EUR', $thirdIncVatPriceList);
     $thirdCallValue = $thirdIncVatPriceList['EUR']->attribute('value');
     $this->assertEquals($firstCallValue, $thirdCallValue);
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:69,代码来源:ezmultipricetype_regression.php


示例2: updateAutoRates

 static function updateAutoRates()
 {
     $error = array('code' => eZExchangeRatesUpdateHandler::OK, 'description' => '');
     $handler = eZExchangeRatesUpdateHandler::create();
     if ($handler) {
         $error = $handler->requestRates();
         if ($error['code'] === eZExchangeRatesUpdateHandler::OK) {
             $rateList = $handler->rateList();
             if (is_array($rateList) && count($rateList) > 0) {
                 $handlerBaseCurrency = $handler->baseCurrency();
                 if ($handlerBaseCurrency) {
                     $shopBaseCurrency = false;
                     $shopINI = eZINI::instance('shop.ini');
                     if ($shopINI->hasVariable('ExchangeRatesSettings', 'BaseCurrency')) {
                         $shopBaseCurrency = $shopINI->variable('ExchangeRatesSettings', 'BaseCurrency');
                     }
                     if (!$shopBaseCurrency) {
                         $shopBaseCurrency = $handlerBaseCurrency;
                     }
                     // update rates for existing currencies
                     //$baseCurrencyCode = $handler->baseCurrency();
                     if (isset($rateList[$shopBaseCurrency]) || $shopBaseCurrency === $handlerBaseCurrency) {
                         // to avoid unnecessary multiplication set $crossBaseRate to 'false';
                         $crossBaseRate = false;
                         if ($shopBaseCurrency !== $handlerBaseCurrency) {
                             $crossBaseRate = 1.0 / (double) $rateList[$shopBaseCurrency];
                             $rateList[$handlerBaseCurrency] = '1.0000';
                         }
                         $currencyList = eZCurrencyData::fetchList();
                         if (is_array($currencyList) && count($currencyList) > 0) {
                             foreach ($currencyList as $currency) {
                                 $rateValue = false;
                                 $currencyCode = $currency->attribute('code');
                                 if (isset($rateList[$currencyCode])) {
                                     $rateValue = $rateList[$currencyCode];
                                     if ($crossBaseRate !== false) {
                                         $rateValue *= $crossBaseRate;
                                     }
                                 } else {
                                     if ($currencyCode === $shopBaseCurrency) {
                                         $rateValue = '1.0000';
                                     }
                                 }
                                 $currency->setAttribute('auto_rate_value', $rateValue);
                                 $currency->sync();
                             }
                         }
                         $error['code'] = eZExchangeRatesUpdateHandler::OK;
                         $error['description'] = ezpI18n::tr('kernel/shop', "'Auto' rates were updated successfully.");
                     } else {
                         $error['code'] = eZExchangeRatesUpdateHandler::INVALID_BASE_CROSS_RATE;
                         $error['description'] = ezpI18n::tr('kernel/shop', "Unable to calculate cross-rate for currency-pair '%1'/'%2'", null, array($handlerBaseCurrency, $shopBaseCurrency));
                     }
                 } else {
                     $error['code'] = eZExchangeRatesUpdateHandler::UNKNOWN_BASE_CURRENCY;
                     $error['description'] = ezpI18n::tr('kernel/shop', 'Unable to determine currency for retrieved rates.');
                 }
             } else {
                 $error['code'] = eZExchangeRatesUpdateHandler::EMPTY_RATE_LIST;
                 $error['description'] = ezpI18n::tr('kernel/shop', 'Retrieved empty list of rates.');
             }
         }
     } else {
         $error['code'] = eZExchangeRatesUpdateHandler::CANT_CREATE_HANDLER;
         $error['description'] = ezpI18n::tr('kernel/shop', 'Unable to create handler to update auto rates.');
     }
     if ($error['code'] !== eZExchangeRatesUpdateHandler::OK) {
         eZDebug::writeError($error['description'], __METHOD__);
     }
     return $error;
 }
开发者ID:nfrp,项目名称:ezpublish,代码行数:71,代码来源:ezshopfunctions.php


示例3: currencyList

    function currencyList()
    {
        if ( !isset( $this->CurrencyList ) )
        {
            $this->CurrencyList = eZCurrencyData::fetchList();
        }

        return $this->CurrencyList;
    }
开发者ID:nottavi,项目名称:ezpublish,代码行数:9,代码来源:ezcurrencyconverter.php


示例4: fetchCurrency

    function fetchCurrency( $code )
    {
        $currency = eZCurrencyData::fetch( $code );
        if ( is_object( $currency ) )
            $result = array( 'result' => $currency );
        else
            $result = array( 'result' => false );

        return $result;
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:10,代码来源:ezshopfunctioncollection.php


示例5: setStatus

 function setStatus($status)
 {
     $statusNumeric = eZCurrencyData::statusStringToNumeric($status);
     if ($statusNumeric !== false) {
         $this->setAttribute('status', $statusNumeric);
     } else {
         eZDebug::writeError("Unknow currency's status '{$status}'", __METHOD__);
     }
 }
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:9,代码来源:ezcurrencydata.php


示例6: switch

    if ($error['code'] != 0) {
        $error['style'] = 'message-error';
    } else {
        $error['style'] = 'message-feedback';
    }
}
switch (eZPreferences::value('currencies_list_limit')) {
    case '2':
        $limit = 25;
        break;
    case '3':
        $limit = 50;
        break;
    default:
        $limit = 10;
        break;
}
// fetch currencies
$currencyList = eZCurrencyData::fetchList(null, true, $offset, $limit);
$currencyCount = eZCurrencyData::fetchListCount();
$viewParameters = array('offset' => $offset);
$tpl = eZTemplate::factory();
$tpl->setVariable('currency_list', $currencyList);
$tpl->setVariable('currency_list_count', $currencyCount);
$tpl->setVariable('limit', $limit);
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('show_error_message', $error !== false);
$tpl->setVariable('error', $error);
$Result = array();
$Result['path'] = array(array('text' => ezpI18n::tr('kernel/shop', 'Available currency list'), 'url' => false));
$Result['content'] = $tpl->fetch("design:shop/currencylist.tpl");
开发者ID:netbliss,项目名称:ezpublish,代码行数:31,代码来源:currencylist.php


示例7: checkCurrency

 function checkCurrency($orderID)
 {
     $returnStatus = array('status' => eZModuleOperationInfo::STATUS_CONTINUE);
     $order = eZOrder::fetch($orderID);
     $productCollection = $order->attribute('productcollection');
     $currencyCode = $productCollection->attribute('currency_code');
     $currencyCode = trim($currencyCode);
     if ($currencyCode == '') {
         $returnStatus = array('status' => eZModuleOperationInfo::STATUS_CANCELLED);
     }
     $locale = eZLocale::instance();
     $localeCurrencyCode = $locale->currencyShortName();
     // Reverse logic to avoid calling eZCurrencyData::currencyExists() if the first expression is true.
     if (!($currencyCode == $localeCurrencyCode or eZCurrencyData::currencyExists($currencyCode))) {
         $returnStatus = array('status' => eZModuleOperationInfo::STATUS_CANCELLED);
     }
     return $returnStatus;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:18,代码来源:ezshopoperationcollection.php


示例8:

                    }
                }
            } else {
                $error = eZCurrencyData::errorMessage($errCode);
            }
        }
    }
}
$pathText = '';
if (strlen($originalCurrencyCode) > 0) {
    // going to edit existing currency
    $pathText = ezpI18n::tr('kernel/shop', 'Edit currency');
    if ($currencyParams['code'] === false) {
        // first time in 'edit' mode? => initialize template variables
        // with existing data.
        $currency = eZCurrencyData::fetch($originalCurrencyCode);
        if (is_object($currency)) {
            $currencyParams['code'] = $currency->attribute('code');
            $currencyParams['symbol'] = $currency->attribute('symbol');
            $currencyParams['locale'] = $currency->attribute('locale');
            $currencyParams['custom_rate_value'] = $currency->attribute('custom_rate_value');
            $currencyParams['rate_factor'] = $currency->attribute('rate_factor');
        } else {
            $error = "'{$originalCurrencyCode}' currency  doesn't exist.";
            $canEdit = false;
        }
    }
} else {
    // going to create new currency
    $pathText = ezpI18n::tr('kernel/shop', 'Create new currency');
}
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:31,代码来源:editcurrency.php


示例9: currencyForLocale

function currencyForLocale($localeString = false)
{
    global $cli;
    global $currencyList;
    $currency = false;
    if ($currencyList === false) {
        $currencyList = eZCurrencyData::fetchList();
    }
    $locale = eZLocale::instance($localeString);
    if (is_object($locale)) {
        // get currency
        if ($currencyCode = $locale->currencyShortName()) {
            if (!isset($currencyList[$currencyCode])) {
                $cli->warning("Currency '{$currencyCode}' doesn't exist");
                $cli->notice("Creating currency '{$currencyCode}'... ", false);
                $currencySymbol = $locale->currencySymbol();
                $localeCode = $locale->localeFullCode();
                if ($currency = eZCurrencyData::create($currencyCode, $currencySymbol, $localeCode, '0.00000', '1.00000', '0.00000')) {
                    $cli->output('Ok');
                    $currency->store();
                    $currencyList[$currencyCode] = $currency;
                } else {
                    $cli->error('Failed');
                }
            } else {
                $currency = $currencyList[$currencyCode];
            }
        } else {
            $cli->error("Unable to find currency code for the '{$localeString}' locale");
        }
    } else {
        $cli->error("Unable to find '{$localeString}' locale");
    }
    return $currency;
}
开发者ID:netbliss,项目名称:ezpublish,代码行数:35,代码来源:convertprice2multiprice.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP eZDB类代码示例发布时间:2022-05-23
下一篇:
PHP eZContentOperationCollection类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap