當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OrderItemInterface::getInventoryUnits方法代碼示例

本文整理匯總了PHP中Sylius\Component\Core\Model\OrderItemInterface::getInventoryUnits方法的典型用法代碼示例。如果您正苦於以下問題:PHP OrderItemInterface::getInventoryUnits方法的具體用法?PHP OrderItemInterface::getInventoryUnits怎麽用?PHP OrderItemInterface::getInventoryUnits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sylius\Component\Core\Model\OrderItemInterface的用法示例。


在下文中一共展示了OrderItemInterface::getInventoryUnits方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: processInventoryUnits

 /**
  * {@inheritdoc}
  */
 public function processInventoryUnits(OrderItemInterface $item)
 {
     $nbUnits = $item->getInventoryUnits()->count();
     if ($item->getQuantity() > $nbUnits) {
         $this->createInventoryUnits($item, $item->getQuantity() - $nbUnits);
     } elseif ($item->getQuantity() < $nbUnits) {
         foreach ($item->getInventoryUnits()->slice(0, $nbUnits - $item->getQuantity()) as $unit) {
             $item->removeInventoryUnit($unit);
         }
     }
     foreach ($item->getInventoryUnits() as $unit) {
         if ($unit->getStockable() !== $item->getVariant()) {
             $unit->setStockable($item->getVariant());
         }
     }
 }
開發者ID:Strontium-90,項目名稱:Sylius,代碼行數:19,代碼來源:InventoryHandler.php

示例2:

 function it_decreases_the_variant_stock_via_inventory_operator($inventoryOperator, $factory, OrderInterface $order, OrderItemInterface $item, ProductVariantInterface $variant, InventoryUnitInterface $unit1, InventoryUnitInterface $unit2, StateMachineInterface $sm1, StateMachineInterface $sm2)
 {
     $order->getItems()->willReturn(array($item));
     $item->getVariant()->willReturn($variant);
     $item->getQuantity()->willReturn(2);
     $item->getInventoryUnits()->shouldBeCalled()->willReturn(array($unit1, $unit2));
     $factory->get($unit1, InventoryUnitTransitions::GRAPH)->willReturn($sm1);
     $sm1->can(InventoryUnitTransitions::SYLIUS_SELL)->willReturn(true);
     $sm1->can(InventoryUnitTransitions::SYLIUS_RELEASE)->willReturn(true);
     $sm1->apply(InventoryUnitTransitions::SYLIUS_SELL)->shouldBeCalled();
     $factory->get($unit2, InventoryUnitTransitions::GRAPH)->willReturn($sm2);
     $sm2->can(InventoryUnitTransitions::SYLIUS_SELL)->willReturn(true);
     $sm2->can(InventoryUnitTransitions::SYLIUS_RELEASE)->willReturn(false);
     $sm2->apply(InventoryUnitTransitions::SYLIUS_SELL)->shouldBeCalled();
     $inventoryOperator->decrease(array($unit1, $unit2))->shouldBeCalled();
     $inventoryOperator->release($variant, 1)->shouldBeCalled();
     $this->updateInventory($order);
 }
開發者ID:aleherse,項目名稱:Sylius,代碼行數:18,代碼來源:InventoryHandlerSpec.php

示例3:

 function it_not_a_backorder_if_contains_no_backordered_units(InventoryUnitInterface $unit1, InventoryUnitInterface $unit2, OrderItemInterface $item)
 {
     $unit1->getInventoryState()->willReturn(InventoryUnitInterface::STATE_SOLD);
     $unit2->getInventoryState()->willReturn(InventoryUnitInterface::STATE_SOLD);
     $item->getInventoryUnits()->willReturn(array($unit1, $unit2));
     $item->setOrder($this)->shouldBeCalled();
     $this->addItem($item);
     $this->shouldNotBeBackorder();
 }
開發者ID:kongqingfu,項目名稱:Sylius,代碼行數:9,代碼來源:OrderSpec.php


注:本文中的Sylius\Component\Core\Model\OrderItemInterface::getInventoryUnits方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。