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


PHP eZCurrencyData::create方法代码示例

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


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

 static function createCurrency($currencyParams)
 {
     $currency = eZCurrencyData::create($currencyParams['code'], $currencyParams['symbol'], $currencyParams['locale'], '0.0000', $currencyParams['custom_rate_value'], $currencyParams['rate_factor']);
     if (is_object($currency)) {
         $db = eZDB::instance();
         $db->begin();
         $currency->store();
         eZMultiPriceData::createPriceListForCurrency($currencyParams['code']);
         $db->commit();
     }
 }
开发者ID:nfrp,项目名称:ezpublish,代码行数:11,代码来源:ezshopfunctions.php

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