本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}