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


PHP OrderInterface::getShipments方法代码示例

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


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

示例1:

    function it_applies_calculated_shipping_charge_for_each_shipment_associated_with_the_order(
        $adjustmentRepository,
        $calculator,
        AdjustmentInterface $adjustment,
        OrderInterface $order,
        ShipmentInterface $shipment,
        ShippingMethodInterface $shippingMethod
    ) {
        $adjustmentRepository->createNew()->willReturn($adjustment);
        $order->getShipments()->willReturn(array($shipment));

        $calculator->calculate($shipment)->willReturn(450);

        $shipment->getMethod()->willReturn($shippingMethod);
        $shippingMethod->getName()->willReturn('FedEx');

        $adjustment->setAmount(450)->shouldBeCalled();
        $adjustment->setType(AdjustmentInterface::SHIPPING_ADJUSTMENT)->shouldBeCalled();
        $adjustment->setDescription('FedEx')->shouldBeCalled();

        $order->removeAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT)->shouldBeCalled();
        $order->addAdjustment($adjustment)->shouldBeCalled();

        $order->calculateTotal()->shouldBeCalled();

        $this->applyShippingCharges($order);
    }
开发者ID:kriswillis,项目名称:Sylius,代码行数:27,代码来源:ShippingChargesProcessorSpec.php

示例2: updateOrderShipmentStates

 /**
  * Update order's shipping state.
  *
  * @param OrderInterface $order
  * @param string         $transition
  */
 public function updateOrderShipmentStates(OrderInterface $order, $transition = ShipmentTransitions::SYLIUS_PREPARE)
 {
     if ($order->isBackorder()) {
         $transition = ShipmentTransitions::SYLIUS_BACKORDER;
     }
     $this->processor->updateShipmentStates($order->getShipments(), $transition);
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:13,代码来源:ShipmentStatesCallback.php

示例3: updateOrderShippingState

 /**
  * @param OrderInterface $order
  */
 public function updateOrderShippingState(OrderInterface $order)
 {
     foreach ($order->getShipments() as $shipment) {
         if ($this->factory->get($shipment, ShipmentTransitions::GRAPH)->can(ShipmentTransitions::SYLIUS_SHIP)) {
             return;
         }
     }
     $this->factory->get($order, OrderTransitions::GRAPH)->apply(OrderTransitions::SYLIUS_SHIP, true);
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:12,代码来源:OrderShipmentCallback.php

示例4:

 function it_does_not_update_order_state_if_one_shipment_is_not_shipped($factory, ShipmentInterface $shipment, OrderInterface $order, StateMachineInterface $sm1, StateMachineInterface $sm2)
 {
     $order->getShipments()->willReturn(array($shipment));
     $factory->get($order, OrderTransitions::GRAPH)->willReturn($sm1);
     $factory->get($shipment, ShipmentTransitions::GRAPH)->willReturn($sm2);
     $sm2->can(ShipmentTransitions::SYLIUS_SHIP)->shouldBeCalled()->willReturn(false);
     $sm1->apply(OrderTransitions::SYLIUS_SHIP, true)->shouldBeCalled();
     $this->updateOrderShippingState($order);
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:9,代码来源:OrderShipmentCallbackSpec.php

示例5:

 function it_marks_order_as_returned_if_all_shipments_were_returned(OrderInterface $order, ShipmentInterface $shipment1, ShipmentInterface $shipment2)
 {
     $order->isBackorder()->shouldBeCalled()->willReturn(false);
     $order->getShipments()->willReturn(array($shipment1, $shipment2));
     $shipment1->getState()->willReturn(ShipmentInterface::STATE_RETURNED);
     $shipment2->getState()->willReturn(ShipmentInterface::STATE_RETURNED);
     $order->setShippingState(OrderShippingStates::RETURNED)->shouldBeCalled();
     $this->resolveShippingState($order);
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:9,代码来源:StateResolverSpec.php

示例6: updateOrderShippingState

 /**
  * Update order shipping state.
  *
  * @param OrderInterface $order
  */
 public function updateOrderShippingState(OrderInterface $order)
 {
     // Check if all shipments are shipped (= transition "ship" cannot be applied)
     foreach ($order->getShipments() as $shipment) {
         if ($this->factory->get($shipment, ShipmentTransitions::GRAPH)->can(ShipmentTransitions::SYLIUS_SHIP)) {
             return;
         }
     }
     $this->factory->get($order, OrderTransitions::GRAPH)->apply(OrderTransitions::SYLIUS_SHIP, true);
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:15,代码来源:OrderShipmentCallback.php

示例7:

 function it_adds_new_inventory_units_to_existing_shipment(OrderInterface $order, ShipmentInterface $shipment, ArrayCollection $shipments, InventoryUnitInterface $inventoryUnit, InventoryUnitInterface $inventoryUnitWithoutShipment)
 {
     $shipments->first()->willReturn($shipment)->shouldBeCalled();
     $inventoryUnit->getShipment()->willReturn($shipment);
     $order->getInventoryUnits()->willReturn(array($inventoryUnit, $inventoryUnitWithoutShipment));
     $order->getShipments()->willReturn($shipments)->shouldBeCalled();
     $shipment->addItem($inventoryUnitWithoutShipment)->shouldBeCalled();
     $shipment->addItem($inventoryUnit)->shouldNotBeCalled();
     $this->createShipment($order);
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:10,代码来源:ShipmentFactorySpec.php

示例8: ArrayCollection

 function it_does_nothing_if_tax_rate_cannot_be_resolved(CalculatorInterface $calculator, TaxRateResolverInterface $taxRateResolver, OrderInterface $order, ShipmentInterface $shipment, ShippingMethodInterface $shippingMethod, ZoneInterface $zone)
 {
     $order->getShippingTotal()->willReturn(100);
     $order->getShipments()->willReturn(new ArrayCollection([$shipment->getWrappedObject()]));
     $shipment->getMethod()->willReturn($shippingMethod);
     $taxRateResolver->resolve($shippingMethod, ['zone' => $zone])->willReturn(null);
     $calculator->calculate(Argument::any())->shouldNotBeCalled();
     $order->addAdjustment(Argument::any())->shouldNotBeCalled();
     $this->apply($order, $zone);
 }
开发者ID:sylius,项目名称:core,代码行数:10,代码来源:OrderShipmentTaxesApplicatorSpec.php

示例9: getOrderShipment

 /**
  * @param OrderInterface $order
  *
  * @return ShipmentInterface
  */
 private function getOrderShipment(OrderInterface $order)
 {
     if ($order->hasShipments()) {
         return $order->getShipments()->first();
     }
     /** @var ShipmentInterface $shipment */
     $shipment = $this->shipmentFactory->createNew();
     $order->addShipment($shipment);
     $shipment->setMethod($this->defaultShippingMethodResolver->getDefaultShippingMethod($shipment));
     return $shipment;
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:16,代码来源:OrderShipmentProcessor.php

示例10:

 function it_adds_new_item_units_to_existing_shipment(OrderInterface $order, ShipmentInterface $shipment, ArrayCollection $shipments, OrderItemUnitInterface $itemUnit, OrderItemUnitInterface $itemUnitWithoutShipment)
 {
     $shipments->first()->willReturn($shipment)->shouldBeCalled();
     $order->hasShipments()->willReturn(true)->shouldBeCalled();
     $itemUnit->getShipment()->willReturn($shipment);
     $order->getItemUnits()->willReturn([$itemUnit, $itemUnitWithoutShipment]);
     $order->getShipments()->willReturn($shipments)->shouldBeCalled();
     $shipment->addUnit($itemUnitWithoutShipment)->shouldBeCalled();
     $shipment->addUnit($itemUnit)->shouldNotBeCalled();
     $this->createForOrder($order);
 }
开发者ID:vikey89,项目名称:Sylius,代码行数:11,代码来源:OrderShipmentFactorySpec.php

示例11: ArrayCollection

 function it_does_not_mark_an_order_if_it_is_already_in_this_shipping_state(FactoryInterface $stateMachineFactory, OrderInterface $order, ShipmentInterface $shipment1, ShipmentInterface $shipment2, StateMachineInterface $orderStateMachine)
 {
     $shipments = new ArrayCollection();
     $shipments->add($shipment1->getWrappedObject());
     $shipments->add($shipment2->getWrappedObject());
     $order->getShipments()->willReturn($shipments);
     $order->getShippingState()->willReturn(OrderShippingStates::STATE_SHIPPED);
     $stateMachineFactory->get($order, OrderShippingTransitions::GRAPH)->willReturn($orderStateMachine);
     $shipment1->getState()->willReturn(ShipmentInterface::STATE_SHIPPED);
     $shipment2->getState()->willReturn(ShipmentInterface::STATE_SHIPPED);
     $orderStateMachine->apply(OrderShippingTransitions::TRANSITION_SHIP)->shouldNotBeCalled();
     $this->resolve($order);
 }
开发者ID:TheMadeleine,项目名称:Sylius,代码行数:13,代码来源:OrderShippingStateResolverSpec.php

示例12: applyShippingCharges

 /**
  * {@inheritdoc}
  */
 public function applyShippingCharges(OrderInterface $order)
 {
     // Remove all shipping adjustments, we recalculate everything from scratch.
     $order->removeAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT);
     foreach ($order->getShipments() as $shipment) {
         $shippingCharge = $this->calculator->calculate($shipment);
         $adjustment = $this->adjustmentFactory->createNew();
         $adjustment->setType(AdjustmentInterface::SHIPPING_ADJUSTMENT);
         $adjustment->setAmount($shippingCharge);
         $adjustment->setDescription($shipment->getMethod()->getName());
         $order->addAdjustment($adjustment);
     }
 }
开发者ID:benakacha,项目名称:Sylius,代码行数:16,代码来源:ShippingChargesProcessor.php

示例13: createShipment

 /**
  * {@inheritdoc}
  */
 public function createShipment(OrderInterface $order)
 {
     $shipment = $order->getShipments()->first();
     if (!$shipment) {
         $shipment = $this->shipmentRepository->createNew();
         $order->addShipment($shipment);
     }
     foreach ($order->getInventoryUnits() as $inventoryUnit) {
         if (null === $inventoryUnit->getShipment()) {
             $shipment->addItem($inventoryUnit);
         }
     }
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:16,代码来源:ShipmentFactory.php

示例14: createForOrder

 /**
  * {@inheritdoc}
  */
 public function createForOrder(OrderInterface $order)
 {
     if ($order->hasShipments()) {
         $shipment = $order->getShipments()->first();
     } else {
         $shipment = $this->shipmentFactory->createNew();
         $order->addShipment($shipment);
     }
     foreach ($order->getItemUnits() as $itemUnit) {
         if (null === $itemUnit->getShipment()) {
             $shipment->addUnit($itemUnit);
         }
     }
 }
开发者ID:vikey89,项目名称:Sylius,代码行数:17,代码来源:OrderShipmentFactory.php

示例15:

 function it_applies_calculated_shipping_charge_for_each_shipment_associated_with_the_order(FactoryInterface $adjustmentFactory, DelegatingCalculatorInterface $calculator, AdjustmentInterface $adjustment, OrderInterface $order, ShipmentInterface $shipment, ShippingMethodInterface $shippingMethod)
 {
     $adjustmentFactory->createNew()->willReturn($adjustment);
     $order->getShipments()->willReturn([$shipment]);
     $calculator->calculate($shipment)->willReturn(450);
     $shipment->getMethod()->willReturn($shippingMethod);
     $shippingMethod->getName()->willReturn('FedEx');
     $adjustment->setAmount(450)->shouldBeCalled();
     $adjustment->setType(AdjustmentInterface::SHIPPING_ADJUSTMENT)->shouldBeCalled();
     $adjustment->setLabel('FedEx')->shouldBeCalled();
     $order->removeAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT)->shouldBeCalled();
     $order->addAdjustment($adjustment)->shouldBeCalled();
     $this->process($order);
 }
开发者ID:origammi,项目名称:Sylius,代码行数:14,代码来源:ShippingChargesProcessorSpec.php


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