當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。