本文整理汇总了PHP中Sylius\Component\Core\Model\OrderItemInterface::getTotal方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderItemInterface::getTotal方法的具体用法?PHP OrderItemInterface::getTotal怎么用?PHP OrderItemInterface::getTotal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Core\Model\OrderItemInterface
的用法示例。
在下文中一共展示了OrderItemInterface::getTotal方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_uses_distributor_and_applicator_to_execute_promotion_action(OrderInterface $order, OrderItemInterface $firstItem, OrderItemInterface $secondItem, PromotionInterface $promotion, ProportionalIntegerDistributorInterface $distributor, UnitsPromotionAdjustmentsApplicatorInterface $unitsPromotionAdjustmentsApplicator)
{
$order->countItems()->willReturn(2);
$order->getItems()->willReturn([$firstItem, $secondItem]);
$firstItem->getTotal()->willReturn(200);
$secondItem->getTotal()->willReturn(800);
$order->getPromotionSubjectTotal()->willReturn(10000);
$distributor->distribute([200, 800], -1000)->willReturn([-200, -800]);
$unitsPromotionAdjustmentsApplicator->apply($order, $promotion, [-200, -800])->shouldBeCalled();
$this->execute($order, ['percentage' => 0.1], $promotion);
}
示例2:
function it_does_not_apply_bigger_promotion_than_promotion_subject_total(OrderInterface $order, OrderItemInterface $firstItem, OrderItemInterface $secondItem, PromotionInterface $promotion, ProportionalIntegerDistributorInterface $proportionalIntegerDistributor, UnitsPromotionAdjustmentsApplicatorInterface $unitsPromotionAdjustmentsApplicator)
{
$order->countItems()->willReturn(2);
$order->getItems()->willReturn(new \ArrayIterator([$firstItem->getWrappedObject(), $secondItem->getWrappedObject()]));
$order->getPromotionSubjectTotal()->willReturn(10000);
$firstItem->getTotal()->willReturn(6000);
$secondItem->getTotal()->willReturn(4000);
$proportionalIntegerDistributor->distribute([6000, 4000], -10000)->willReturn([-6000, -4000]);
$unitsPromotionAdjustmentsApplicator->apply($order, $promotion, [-6000, -4000])->shouldBeCalled();
$this->execute($order, ['amount' => 15000], $promotion);
}
示例3:
function it_does_not_recognize_a_subject_as_eligible_if_items_from_required_taxon_has_too_low_total(TaxonRepositoryInterface $taxonRepository, OrderInterface $order, OrderItemInterface $compositeBowItem, OrderItemInterface $longswordItem, ProductInterface $compositeBow, ProductInterface $longsword, TaxonInterface $bows)
{
$order->getItems()->willReturn([$compositeBowItem, $longswordItem]);
$taxonRepository->findOneBy(['code' => 'bows'])->willReturn($bows);
$compositeBowItem->getProduct()->willReturn($compositeBow);
$compositeBow->hasTaxon($bows)->willReturn(true);
$compositeBowItem->getTotal()->willReturn(5000);
$longswordItem->getProduct()->willReturn($longsword);
$longsword->hasTaxon($bows)->willReturn(false);
$longswordItem->getTotal()->willReturn(4000);
$this->isEligible($order, ['taxon' => 'bows', 'amount' => 10000])->shouldReturn(false);
}
示例4:
function it_does_not_apply_promotions_with_amount_0($adjustmentFactory, $distributor, $originator, $priceRangeFilter, $taxonFilter, AdjustmentInterface $promotionAdjustment1, Collection $originalItems, Collection $units, OrderInterface $order, OrderItemInterface $orderItem1, OrderItemInterface $orderItem2, OrderItemInterface $orderItem3, OrderItemUnitInterface $unit1, OrderItemUnitInterface $unit2, PromotionInterface $promotion)
{
$order->getItems()->willReturn($originalItems);
$originalItems->toArray()->willReturn([$orderItem1, $orderItem2, $orderItem3]);
$priceRangeFilter->filter([$orderItem1, $orderItem2, $orderItem3], ['percentage' => 0.2, 'filters' => ['taxons' => ['testTaxon']]])->willReturn([$orderItem1, $orderItem2]);
$taxonFilter->filter([$orderItem1, $orderItem2], ['percentage' => 0.2, 'filters' => ['taxons' => ['testTaxon']]])->willReturn([$orderItem1]);
$orderItem1->getQuantity()->willReturn(2);
$orderItem1->getUnits()->willReturn($units);
$units->getIterator()->willReturn(new \ArrayIterator([$unit1->getWrappedObject(), $unit2->getWrappedObject()]));
$orderItem1->getTotal()->willReturn(5);
$distributor->distribute(1, 2)->willReturn([1, 0]);
$promotion->getDescription()->willReturn('Test description');
$adjustmentFactory->createNew()->willReturn($promotionAdjustment1);
$promotionAdjustment1->setType(AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT)->shouldBeCalled();
$promotionAdjustment1->setLabel('Test description')->shouldBeCalled();
$promotionAdjustment1->setAmount(-1)->shouldBeCalled();
$originator->setOrigin($promotionAdjustment1, $promotion)->shouldBeCalled();
$unit1->addAdjustment($promotionAdjustment1)->shouldBeCalled();
$unit2->addAdjustment(Argument::any())->shouldNotBeCalled();
$this->execute($order, ['percentage' => 0.2, 'filters' => ['taxons' => ['testTaxon']]], $promotion);
}
示例5:
function it_does_not_include_shipping_promotion_adjustment_in_order_promotion_total(AdjustmentInterface $shippingPromotionAdjustment, OrderItemInterface $orderItem1)
{
$orderItem1->getTotal()->willReturn(500);
$orderItem1->getAdjustmentsTotalRecursively(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->willReturn(-400);
$shippingPromotionAdjustment->getType()->willReturn(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT);
$shippingPromotionAdjustment->isNeutral()->willReturn(false);
$shippingPromotionAdjustment->getAmount()->willReturn(-100);
$orderItem1->setOrder($this)->shouldBeCalled();
$this->addItem($orderItem1);
$shippingPromotionAdjustment->setAdjustable($this)->shouldBeCalled();
$this->addAdjustment($shippingPromotionAdjustment);
$this->getOrderPromotionTotal()->shouldReturn(-400);
}
示例6: tax
function it_does_not_apply_taxes_with_amount_0($adjustmentsFactory, $calculator, $distributor, $taxRateResolver, Collection $items, Collection $units, OrderInterface $order, OrderItemInterface $orderItem, OrderItemUnitInterface $unit1, OrderItemUnitInterface $unit2, ProductVariantInterface $productVariant, TaxRateInterface $taxRate, ZoneInterface $zone)
{
$order->getItems()->willReturn($items);
$items->count()->willReturn(1);
$items->getIterator()->willReturn(new \ArrayIterator([$orderItem->getWrappedObject()]));
$orderItem->getQuantity()->willReturn(2);
$orderItem->getVariant()->willReturn($productVariant);
$taxRateResolver->resolve($productVariant, ['zone' => $zone])->willReturn($taxRate);
$orderItem->getTotal()->willReturn(1000);
$calculator->calculate(1000, $taxRate)->willReturn(0);
$taxRate->getLabel()->willReturn('Simple tax (0%)');
$taxRate->isIncludedInPrice()->willReturn(false);
$orderItem->getUnits()->willReturn($units);
$units->getIterator()->willReturn(new \ArrayIterator([$unit1->getWrappedObject(), $unit2->getWrappedObject()]));
$distributor->distribute(0, 2)->willReturn([0, 0]);
$adjustmentsFactory->createWithData(AdjustmentInterface::TAX_ADJUSTMENT, 'Simple tax (0%)', 0, false)->shouldNotBeCalled();
$this->apply($order, $zone);
}
示例7:
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->getUnits()->willReturn([$unit1, $unit2]);
$item->getTotal()->willReturn(4000);
$item->setOrder($this)->shouldBeCalled();
$this->addItem($item);
$this->shouldNotBeBackorder();
}
示例8: ArrayCollection
function it_does_not_recognize_a_subject_as_eligible_if_items_from_required_taxon_has_too_low_total(ChannelInterface $channel, OrderInterface $order, OrderItemInterface $compositeBowItem, OrderItemInterface $longswordItem, ProductInterface $compositeBow, ProductInterface $longsword, ProductTaxonInterface $bowsProductTaxon, TaxonInterface $bows, TaxonRepositoryInterface $taxonRepository)
{
$order->getChannel()->willReturn($channel);
$channel->getCode()->willReturn('WEB_US');
$order->getItems()->willReturn([$compositeBowItem, $longswordItem]);
$taxonRepository->findOneBy(['code' => 'bows'])->willReturn($bows);
$compositeBowItem->getProduct()->willReturn($compositeBow);
$compositeBow->filterProductTaxonsByTaxon($bows)->willReturn(new ArrayCollection([$bowsProductTaxon]));
$compositeBowItem->getTotal()->willReturn(5000);
$longswordItem->getProduct()->willReturn($longsword);
$longsword->filterProductTaxonsByTaxon($bows)->willReturn(new ArrayCollection([]));
$longswordItem->getTotal()->willReturn(4000);
$this->isEligible($order, ['WEB_US' => ['taxon' => 'bows', 'amount' => 10000]])->shouldReturn(false);
}
示例9:
function it_returns_promotions_total_recursively(AdjustmentInterface $orderPromotionAdjustment, AdjustmentInterface $orderItemPromotionAdjustment, OrderItemInterface $orderItem)
{
$orderPromotionAdjustment->getAmount()->willReturn(10000);
$orderItemPromotionAdjustment->getAmount()->willReturn(5000);
$orderPromotionAdjustment->isNeutral()->willReturn(false);
$orderItemPromotionAdjustment->isNeutral()->willReturn(false);
$orderPromotionAdjustment->getType()->willReturn(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT);
$orderItemPromotionAdjustment->getType()->willReturn(AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT);
$orderPromotionAdjustment->setAdjustable($this)->shouldBeCalled();
$orderItem->getAdjustmentsRecursively(AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT)->willReturn([$orderItemPromotionAdjustment]);
$orderItem->setOrder($this)->shouldBeCalled();
$orderItem->getTotal()->willReturn(15000);
$orderItem->getAdjustmentsRecursively(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->willReturn([]);
$this->addItem($orderItem);
$this->addAdjustment($orderPromotionAdjustment);
$this->getPromotionsTotalRecursively()->shouldReturn(15000);
}