当前位置: 首页>>代码示例>>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;未经允许,请勿转载。