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


PHP Money::subtract方法代码示例

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


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

示例1: getShippingTotal

 /** Calculate shipping cost (Also set free shipping)
  * @param Money $totalSubtotal
  * @param $orderItems
  * @return array
  * @internal param Money $credits
  */
 public function getShippingTotal(Money $totalSubtotal, $orderItems, $zipCode = null)
 {
     $hasFreeShipping = FALSE;
     $shipping = [];
     $market_check = Configure::read('market_id');
     if (!empty($market_check)) {
         $market_id = Configure::read('market_id');
     } else {
         $market_id = $this->getMarketId();
     }
     //shipping tiers
     // market touch point
     $trait = ClassRegistry::init('TraitCountry');
     $defaultShipping = Money::fromFloat($trait->getTrait($market_id, 'default_shipping'));
     $midTierShipping = Money::fromFloat($trait->getTrait($market_id, 'mid_shipping_tier'));
     $marketShippingTierMid = Money::fromFloat($trait->getTrait($market_id, 'market_shipping_mid_tier'));
     $marketShippingTierFree = Money::fromFloat($trait->getTrait($market_id, 'market_shipping_free_tier'));
     $total_weight = 0.0;
     $no_expedite_reason = array();
     $backordered_items = false;
     $items = 0;
     $backorder_num = 0;
     $expedite = true;
     if (Configure::read('market_id') != MARKET::MARKET_USA) {
         $expedite = false;
         $no_expedite_reason[] = 1;
         //Currently none expeditable market
     }
     $expedite_check = $this->getExpeditedShipCount();
     if (!$expedite_check) {
         $expedite = false;
         $no_expedite_reason[] = 2;
         //Limit exceeded for expedited shipping requests
     }
     foreach ($orderItems as $key => $item) {
         $items++;
         if ($item['backordered'] == true) {
             $backordered_items = true;
             $this->orderObject->backOrderCount += (int) $item['qty'];
             //backorder
         }
         if ($item['childBackordered'] == true) {
             $backordered_items = true;
         }
         if ($item['sku'] == 'US-12001-01') {
             $expedite = false;
             $no_expedite_reason[] = 4;
             //hazmat
         }
         if ($item['hazmat'] == TRUE) {
             $expedite = false;
             $no_expedite_reason[] = 4;
             //hazmat
         }
         if (!empty($item['weight'])) {
             $total_weight += $item['weight'];
         } else {
             $total_weight += 0.35;
         }
         $shipping[$key] = $defaultShipping;
         // Convention tickets have free shipping + Presenter Kits
         if (in_array($item['item_type_id'], [Item::TYPE_CONVENTION_TICKET])) {
             $hasFreeShipping = TRUE;
         }
         // Items with free shipping (guest passes)
         if (in_array($item['sku'], ProductGlobal::freeShipping())) {
             $hasFreeShipping = TRUE;
         }
         // Remove business supplies from subtotal
         if ($item['item_type_id'] == Item::TYPE_SUPPLIES || $item['item_type_id'] == Item::TYPE_SUPPLIES_SETS) {
             $totalSubtotal->subtract($item['subtotal']);
         }
         // Remove presenter kits from subtotal
         if ($item['item_type_id'] == Item::TYPE_PRESENTER_KIT) {
             $totalSubtotal->subtract($item['subtotal']);
         }
     }
     if (CakeSession::read('market_id') != $market_id) {
         $this->orderObject->backOrderCount = 0;
         $wid = WarehouseUtil::idByMarket($market_id);
         Configure::write('ns_warehouse_id', $wid);
         $locale = CakeSession::read('Config');
         $locale = $locale['language'];
         /**
          * Get Cart
          */
         $results = ['backordered' => [], 'unavailable' => []];
         /**
          * Get availability for cart items
          */
         $this->Item = ClassRegistry::init('Item');
         $this->NsWarehouse = ClassRegistry::init('NsWarehouse');
         foreach ($orderItems as $key => $item) {
             $itemCheck = $this->Item->detailsBySku($item['sku'], $locale, true);
//.........这里部分代码省略.........
开发者ID:kameshwariv,项目名称:testexample,代码行数:101,代码来源:Order.php

示例2: testExceptionIsRaisedWhenMoneyObjectWithDifferentCurrencyIsSubtracted

 /**
  * @covers            \SebastianBergmann\Money\Money::subtract
  * @covers            \SebastianBergmann\Money\Money::assertSameCurrency
  * @uses              \SebastianBergmann\Money\Money::__construct
  * @uses              \SebastianBergmann\Money\Money::handleCurrencyArgument
  * @uses              \SebastianBergmann\Money\Money::getAmount
  * @uses              \SebastianBergmann\Money\Money::getCurrency
  * @uses              \SebastianBergmann\Money\Currency
  * @expectedException \SebastianBergmann\Money\CurrencyMismatchException
  */
 public function testExceptionIsRaisedWhenMoneyObjectWithDifferentCurrencyIsSubtracted()
 {
     $a = new Money(1, new Currency('EUR'));
     $b = new Money(2, new Currency('USD'));
     $b->subtract($a);
 }
开发者ID:erictho,项目名称:money,代码行数:16,代码来源:MoneyTest.php

示例3: subtractMoney

 /**
  * subtractMoney
  * 
  * Adds two instances of Money together, returning a new instance in the
  * same currency as the first instance.
  * 
  * @param Money $first
  * @param Money $second
  * @return type
  */
 public function subtractMoney(Money $first, Money $second)
 {
     return $first->subtract($this->normalizeMoneyValue($first, $second));
 }
开发者ID:mcordingley,项目名称:money,代码行数:14,代码来源:Broker.php


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