/**
  * {@inheritdoc}
  */
 public function holdInventory(OrderInterface $order)
 {
     foreach ($order->getItems() as $item) {
         $quantity = $this->applyTransition($item->getUnits(), InventoryUnitTransitions::SYLIUS_HOLD);
         $this->inventoryOperator->hold($item->getVariant(), $quantity);
     }
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function updateInventory(OrderInterface $order)
 {
     foreach ($order->getItems() as $item) {
         $units = $item->getUnits();
         $quantity = 0;
         foreach ($units as $unit) {
             $stateMachine = $this->stateMachineFactory->get($unit, InventoryUnitTransitions::GRAPH);
             if ($stateMachine->can(InventoryUnitTransitions::SYLIUS_SELL)) {
                 if ($stateMachine->can(InventoryUnitTransitions::SYLIUS_RELEASE)) {
                     ++$quantity;
                 }
                 $stateMachine->apply(InventoryUnitTransitions::SYLIUS_SELL);
             }
         }
         $this->inventoryOperator->release($item->getVariant(), $quantity);
         $this->inventoryOperator->decrease($units);
     }
 }