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


PHP Price类代码示例

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


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

示例1: fromJson

 public static function fromJson($json)
 {
     $r = new Price();
     $r->setGross($json->gross);
     $r->setCurrency($json->currency);
     return $r;
 }
开发者ID:purchased-at,项目名称:sdk-php,代码行数:7,代码来源:Price.php

示例2: testPricesWithNoTax

 public function testPricesWithNoTax()
 {
     $price = new Price(100, Price::NETTO, -1);
     $this->assertEquals(100, $price->convertTo(Price::NETTO));
     $this->assertEquals(100, $price->convertTo(Price::BRUTTO));
     $this->assertEquals(0, $price->convertTo(Price::TAX));
 }
开发者ID:pscheit,项目名称:psc-cms,代码行数:7,代码来源:PriceTest.php

示例3: import_csv

 protected function import_csv()
 {
     set_time_limit(0);
     $file_name = dirname(APPLICATION_PATH) . '/files/price.csv';
     if (file_exists($file_name)) {
         $Price = new Price();
         $f = fopen($file_name, 'r');
         echo getdate() . "<BR>";
         while (!feof($f)) {
             $s = fgets($f);
             $s = trim($s);
             if ($s != '') {
                 $ar = split(';', $s);
                 if ($ar[1] == '2') {
                     $data = array('id_product' => $ar[0], 'exists_type' => $ar[1], 'price' => $ar[2]);
                     if (!($er = $Price->add($data))) {
                         print_r($data);
                         print_r('error=' . $er);
                         exit;
                     }
                 }
             }
         }
         echo getdate();
         fclose($f);
     } else {
         echo 'file not found';
     }
 }
开发者ID:vitsun,项目名称:igrushki-detkam,代码行数:29,代码来源:ServicePriceController.php

示例4: Amount

 public function Amount($order)
 {
     $shopConfig = ShopConfig::current_shop_config();
     $amount = new Price();
     $amount->setAmount($order->SubTotal()->getAmount() * ($this->Rate / 100));
     $amount->setCurrency($shopConfig->BaseCurrency);
     $amount->setSymbol($shopConfig->BaseCurrencySymbol);
     return $amount;
 }
开发者ID:helpfulrobot,项目名称:swipestripe-swipestripe-flatfeetax,代码行数:9,代码来源:FlatFeeTaxRate.php

示例5: updateAmount

 /**
  * Choose Discounted price depending on current member's StreakDiscountType.
  *
  * @param Price $amount
  */
 public function updateAmount($amount)
 {
     // only if we are on a front-end page
     if (Controller::curr() instanceof Page_Controller) {
         if ($discountedPrice = $this->discountedPrice()) {
             $amount->setAmount($discountedPrice);
         }
     }
 }
开发者ID:swipestreak,项目名称:discounts,代码行数:14,代码来源:Discountable.php

示例6: testPayload

 public function testPayload()
 {
     $p = new Price();
     foreach ($this->payload as $testCase) {
         echo "Testing case: " . json_encode($testCase) . "\n";
         $p->setPricePerMinute($testCase["ppm"]);
         $this->assertEquals($p->calculateCallCost($testCase["duration"]), $testCase["result"]);
     }
 }
开发者ID:luizcapu,项目名称:scuptel,代码行数:9,代码来源:PriceTest.php

示例7: getPriceForDays

 public function getPriceForDays($days)
 {
     $price = Price::fromString('0', $this->price->getCurrency());
     while ($days > 0) {
         $days -= $this->unitInDays;
         $price = $price->add($this->price);
     }
     return $price;
 }
开发者ID:weblee,项目名称:equipment-rental,代码行数:9,代码来源:Rate.php

示例8: testCurrencyPairsConversions

 public function testCurrencyPairsConversions()
 {
     $price = new Price(array('EUR' => 5, 'USD' => 10, 'GBP' => 15), array('USD/CHF 1.500'));
     $conversions = $price->getConversions();
     $this->assertCount(1, $conversions);
     $this->assertInstanceOf('Money\\CurrencyPair', $conversions[0]);
     $this->assertEquals('USD', $conversions[0]->getBaseCurrency());
     $this->assertEquals('CHF', $conversions[0]->getCounterCurrency());
     $this->assertEquals(1.5, $conversions[0]->getRatio());
 }
开发者ID:leaphly,项目名称:price,代码行数:10,代码来源:ConversionPriceTest.php

示例9: Amount

 public function Amount()
 {
     // TODO: Multi currency
     $shopConfig = ShopConfig::current_shop_config();
     $amount = new Price();
     $amount->setAmount($this->Price);
     $amount->setCurrency($shopConfig->BaseCurrency);
     $amount->setSymbol($shopConfig->BaseCurrencySymbol);
     $this->extend('updateAmount', $amount);
     return $amount;
 }
开发者ID:helpfulrobot,项目名称:swipestripe-swipestripe-flatfeeshipping,代码行数:11,代码来源:FlatFeeShippingRate.php

示例10: testShouldBeImmutable

 public function testShouldBeImmutable()
 {
     $p1ArrayMoney = ['EUR' => 100, 'GBP' => 101];
     $p2ArrayMoney = ['EUR' => 100];
     $p2ArrayCurrency = ['EUR/GBP 1.100'];
     $price1 = new Price($p1ArrayMoney);
     $price2 = new Price($p2ArrayMoney, $p2ArrayCurrency);
     $priceAdd = $price1->add($price2);
     $priceMul = $price1->multiply(2);
     $this->assertEquals(new Price($p1ArrayMoney), $price1);
     $this->assertEquals(new Price($p2ArrayMoney, $p2ArrayCurrency), $price2);
 }
开发者ID:leaphly,项目名称:price,代码行数:12,代码来源:ConversionCoherencyTest.php

示例11: testPayload

 public function testPayload()
 {
     $price = new Price();
     $plan = new Plan();
     foreach ($this->payload as $testCase) {
         echo "Testing case: " . json_encode($testCase) . "\n";
         $price->setPricePerMinute($testCase["price"]["ppm"]);
         $plan->setMinutes($testCase["plan"]["min"]);
         $plan->setFareAdditionalMin($testCase["plan"]["fare"]);
         $this->assertEquals($plan->calculateCallCost($price, $testCase["duration"]), $testCase["result"]);
     }
 }
开发者ID:luizcapu,项目名称:scuptel,代码行数:12,代码来源:PlanTest.php

示例12: toObject

 private function toObject($row)
 {
     $obj = new Price();
     if (isset($row["from_ddd"])) {
         $obj->setFromDDD($row["from_ddd"]);
     }
     if (isset($row["to_ddd"])) {
         $obj->setToDDD($row["to_ddd"]);
     }
     if (isset($row["price_per_minute"])) {
         $obj->setPricePerMinute($row["price_per_minute"]);
     }
     return $obj;
 }
开发者ID:luizcapu,项目名称:scuptel,代码行数:14,代码来源:PriceDao.class.php

示例13: __construct

 public function __construct($controller, $name, $quantity = null, $redirectURL = null)
 {
     parent::__construct($controller, $name, FieldList::create(), FieldList::create(), null);
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript('swipestripe/javascript/ProductForm.js');
     $this->product = $controller->data();
     $this->quantity = $quantity;
     $this->redirectURL = $redirectURL;
     $this->fields = $this->createFields();
     $this->actions = $this->createActions();
     $this->validator = $this->createValidator();
     $this->setupFormErrors();
     $this->addExtraClass('product-form');
     //Add a map of all variations and prices to the page for updating the price
     $map = array();
     $variations = $this->product->Variations();
     $productPrice = $this->product->Price();
     if ($variations && $variations->exists()) {
         foreach ($variations as $variation) {
             if ($variation->isEnabled()) {
                 $variationPrice = $variation->Price();
                 $amount = Price::create();
                 $amount->setAmount($productPrice->getAmount() + $variationPrice->getAmount());
                 $amount->setCurrency($productPrice->getCurrency());
                 $amount->setSymbol($productPrice->getSymbol());
                 $map[] = array('price' => $amount->Nice(), 'options' => $variation->Options()->column('ID'), 'free' => _t('Product.FREE', 'Free'));
             }
         }
     }
     $this->setAttribute('data-map', json_encode($map));
 }
开发者ID:vinstah,项目名称:body,代码行数:32,代码来源:ProductForm.php

示例14: setList

 public static function setList($list)
 {
     $sql = 'UPDATE {{catalog}} SET available=0';
     DB::exec($sql);
     foreach ($list as $partname => $items) {
         $sql = 'SELECT tree FROM {{catalog}} WHERE partname="' . $partname . '"';
         $parent = DB::getOne($sql);
         if ($parent) {
             $available = 0;
             foreach ($items as $size => $item) {
                 $sql = 'SELECT id FROM {{tree}} WHERE parent=' . $parent . ' AND name="' . $size . '"';
                 $tree = DB::getOne($sql);
                 if (!$tree) {
                     $sql = 'SELECT id FROM {{tree}} WHERE parent=' . $parent . ' AND path="' . $size . '"';
                     $tree = DB::getOne($sql);
                 }
                 foreach ($item as $k => $f) {
                     $sql = 'SELECT type FROM {{fields}} WHERE module=6 AND path="' . $k . '"';
                     $r = DB::getOne($sql);
                     $row = array('field' => Fields::$types[$r]['type'], 'path' => $k, 'value' => $f);
                     Price::updateField($tree, $row);
                     if ($k == 'numberRetailSales' && $f > 0) {
                         $available = 1;
                     }
                 }
             }
             $sql = 'UPDATE {{catalog}} SET available=' . $available . ' WHERE tree=' . $parent;
             DB::exec($sql);
         }
     }
 }
开发者ID:sov-20-07,项目名称:billing,代码行数:31,代码来源:PriceModel.php

示例15: getFormFields

 /**
  * Get the form fields for the OrderForm.
  * 
  * @return FieldList List of fields
  */
 public function getFormFields()
 {
     $fields = new FieldList();
     $field = new XeroTaxModifierField($this, _t('Xero.TAX', 'Tax'));
     $shopConfig = ShopConfig::current_shop_config();
     $amount = new Price();
     $amount->setAmount($this->Price);
     $amount->setCurrency($shopConfig->BaseCurrency);
     $amount->setSymbol($shopConfig->BaseCurrencySymbol);
     $field->setAmount($amount);
     $fields->push($field);
     if (!$fields->exists()) {
         Requirements::javascript('swipestripe-flatfeetax/javascript/FlatFeeTaxModifierField.js');
     }
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:swipestripe-swipestripe-xero,代码行数:21,代码来源:XeroTaxModification.php


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