本文整理汇总了PHP中Sylius\Component\Core\Model\OrderItemInterface::getQuantity方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderItemInterface::getQuantity方法的具体用法?PHP OrderItemInterface::getQuantity怎么用?PHP OrderItemInterface::getQuantity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Core\Model\OrderItemInterface
的用法示例。
在下文中一共展示了OrderItemInterface::getQuantity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_applies_percentage_discount_on_every_unit_in_order(FactoryInterface $adjustmentFactory, FilterInterface $priceRangeFilter, FilterInterface $taxonFilter, FilterInterface $productFilter, AdjustmentInterface $promotionAdjustment1, AdjustmentInterface $promotionAdjustment2, Collection $originalItems, Collection $units, OrderInterface $order, OrderItemInterface $orderItem1, OrderItemUnitInterface $unit1, OrderItemUnitInterface $unit2, PromotionInterface $promotion)
{
$order->getItems()->willReturn($originalItems);
$originalItems->toArray()->willReturn([$orderItem1]);
$priceRangeFilter->filter([$orderItem1], ['percentage' => 0.2])->willReturn([$orderItem1]);
$taxonFilter->filter([$orderItem1], ['percentage' => 0.2])->willReturn([$orderItem1]);
$productFilter->filter([$orderItem1], ['percentage' => 0.2])->willReturn([$orderItem1]);
$orderItem1->getQuantity()->willReturn(2);
$orderItem1->getUnits()->willReturn($units);
$units->getIterator()->willReturn(new \ArrayIterator([$unit1->getWrappedObject(), $unit2->getWrappedObject()]));
$orderItem1->getUnitPrice()->willReturn(500);
$promotion->getName()->willReturn('Test promotion');
$promotion->getCode()->willReturn('TEST_PROMOTION');
$adjustmentFactory->createNew()->willReturn($promotionAdjustment1, $promotionAdjustment2);
$promotionAdjustment1->setType(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT)->shouldBeCalled();
$promotionAdjustment1->setLabel('Test promotion')->shouldBeCalled();
$promotionAdjustment1->setAmount(-100)->shouldBeCalled();
$promotionAdjustment1->setOriginCode('TEST_PROMOTION')->shouldBeCalled();
$promotionAdjustment2->setType(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT)->shouldBeCalled();
$promotionAdjustment2->setLabel('Test promotion')->shouldBeCalled();
$promotionAdjustment2->setAmount(-100)->shouldBeCalled();
$promotionAdjustment2->setOriginCode('TEST_PROMOTION')->shouldBeCalled();
$unit1->addAdjustment($promotionAdjustment1)->shouldBeCalled();
$unit2->addAdjustment($promotionAdjustment2)->shouldBeCalled();
$this->execute($order, ['percentage' => 0.2], $promotion);
}
示例2:
function it_returns_regular_price_of_discount_order_item(OrderItemInterface $orderItem)
{
$orderItem->getQuantity()->willReturn(2);
$orderItem->getUnitPrice()->willReturn(1000);
$orderItem->getAdjustmentsTotalRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->willReturn(1000);
$this->getRegularPrice($orderItem)->shouldReturn(3000);
}
示例3:
function it_executes_request(InvoiceNumberGeneratorInterface $invoiceNumberGenerator, CurrencyConverterInterface $currencyConverter, Convert $request, PaymentInterface $payment, OrderInterface $order, OrderItemInterface $orderItem, ProductVariantInterface $productVariant, ProductInterface $product)
{
$request->getTo()->willReturn('array');
$payment->getId()->willReturn(19);
$order->getId()->willReturn(92);
$order->getId()->willReturn(92);
$order->getCurrencyCode()->willReturn('PLN');
$order->getTotal()->willReturn(22000);
$order->getItems()->willReturn([$orderItem]);
$order->getAdjustmentsTotalRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->willReturn(0);
$order->getOrderPromotionTotal()->willReturn(0);
$order->getShippingTotal()->willReturn(2000);
$orderItem->getVariant()->willReturn($productVariant);
$orderItem->getDiscountedUnitPrice()->willReturn(20000);
$orderItem->getQuantity()->willReturn(1);
$productVariant->getProduct()->willReturn($product);
$product->getName()->willReturn('Lamborghini Aventador Model');
$request->getSource()->willReturn($payment);
$payment->getOrder()->willReturn($order);
$invoiceNumberGenerator->generate($order, $payment)->willReturn('19-92');
$currencyConverter->convertFromBase(22000, 'PLN')->willReturn(88000);
$currencyConverter->convertFromBase(20000, 'PLN')->willReturn(80000);
$currencyConverter->convertFromBase(2000, 'PLN')->willReturn(8000);
$details = ['PAYMENTREQUEST_0_INVNUM' => '19-92', 'PAYMENTREQUEST_0_CURRENCYCODE' => 'PLN', 'PAYMENTREQUEST_0_AMT' => 880.0, 'PAYMENTREQUEST_0_ITEMAMT' => 880.0, 'L_PAYMENTREQUEST_0_NAME0' => 'Lamborghini Aventador Model', 'L_PAYMENTREQUEST_0_AMT0' => 800.0, 'L_PAYMENTREQUEST_0_QTY0' => 1, 'L_PAYMENTREQUEST_0_NAME1' => 'Shipping Total', 'L_PAYMENTREQUEST_0_AMT1' => 80.0, 'L_PAYMENTREQUEST_0_QTY1' => 1];
$request->setResult($details)->shouldBeCalled();
$this->execute($request);
}
示例4:
function it_does_not_apply_bigger_promotions_than_unit_total($adjustmentFactory, $originator, $priceRangeFilter, $taxonFilter, AdjustmentInterface $promotionAdjustment1, AdjustmentInterface $promotionAdjustment2, 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], ['amount' => 1000, 'filters' => ['taxons' => ['testTaxon']]])->willReturn([$orderItem1, $orderItem3]);
$taxonFilter->filter([$orderItem1, $orderItem3], ['amount' => 1000, 'filters' => ['taxons' => ['testTaxon']]])->willReturn([$orderItem1]);
$orderItem1->getQuantity()->willReturn(2);
$orderItem1->getUnits()->willReturn($units);
$units->getIterator()->willReturn(new \ArrayIterator([$unit1->getWrappedObject(), $unit2->getWrappedObject()]));
$promotion->getName()->willReturn('Test promotion');
$adjustmentFactory->createNew()->willReturn($promotionAdjustment1, $promotionAdjustment2);
$unit1->getTotal()->willReturn(300);
$promotionAdjustment1->setType(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT)->shouldBeCalled();
$promotionAdjustment1->setLabel('Test promotion')->shouldBeCalled();
$promotionAdjustment1->setAmount(-300)->shouldBeCalled();
$originator->setOrigin($promotionAdjustment1, $promotion)->shouldBeCalled();
$unit2->getTotal()->willReturn(200);
$promotionAdjustment2->setType(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT)->shouldBeCalled();
$promotionAdjustment2->setLabel('Test promotion')->shouldBeCalled();
$promotionAdjustment2->setAmount(-200)->shouldBeCalled();
$originator->setOrigin($promotionAdjustment2, $promotion)->shouldBeCalled();
$unit1->addAdjustment($promotionAdjustment1)->shouldBeCalled();
$unit2->addAdjustment($promotionAdjustment2)->shouldBeCalled();
$this->execute($order, ['amount' => 1000, 'filters' => ['taxons' => ['testTaxon']]], $promotion);
}
示例5:
function it_does_nothing_if_target_quantity_is_below_0($orderItemUnitFactory, OrderItemInterface $orderItem)
{
$orderItem->getQuantity()->willReturn(3);
$orderItemUnitFactory->createForItem(Argument::any())->shouldNotBeCalled();
$orderItem->addUnit(Argument::any())->shouldNotBeCalled();
$orderItem->removeUnit(Argument::any())->shouldNotBeCalled();
$this->modify($orderItem, -10);
}
示例6: isItemEligible
/**
* @param OrderItemInterface $item
* @param array $configuration
*
* @return bool
*/
private function isItemEligible(OrderItemInterface $item, array $configuration)
{
if (!$configuration['exclude']) {
if (isset($configuration['count'])) {
return $this->isItemQuantityEligible($item->getQuantity(), $configuration);
}
return true;
}
return false;
}
示例7:
function it_throws_exception_when_recalculated_on_hand_quantity_is_lower_than_zero(OrderInterface $order, OrderItemInterface $orderItem, ProductVariantInterface $productVariant)
{
$order->getItems()->willReturn([$orderItem]);
$orderItem->getQuantity()->willReturn(5);
$orderItem->getVariant()->willReturn($productVariant);
$productVariant->isTracked()->willReturn(true);
$productVariant->getOnHand()->willReturn(4);
$productVariant->getName()->willReturn('Variant');
$this->shouldThrow(\InvalidArgumentException::class)->during('decrease', [$order]);
}
示例8:
function it_recalculates_prices_without_adding_anything_to_the_context_if_its_not_needed(DelegatingCalculatorInterface $priceCalculator, OrderInterface $order, OrderItemInterface $item, PriceableInterface $variant)
{
$order->getCustomer()->willReturn(null);
$order->getChannel()->willReturn(null);
$order->getItems()->willReturn([$item]);
$item->isImmutable()->willReturn(false);
$item->getQuantity()->willReturn(5);
$item->getVariant()->willReturn($variant);
$priceCalculator->calculate($variant, ['quantity' => 5])->willReturn(10);
$item->setUnitPrice(10)->shouldBeCalled();
$this->process($order);
}
示例9: applyAdjustmentsOnItemUnits
/**
* @param OrderItemInterface $item
* @param PromotionInterface $promotion
* @param int $itemPromotionAmount
*/
private function applyAdjustmentsOnItemUnits(OrderItemInterface $item, PromotionInterface $promotion, $itemPromotionAmount)
{
$splitPromotionAmount = $this->distributor->distribute($itemPromotionAmount, $item->getQuantity());
$i = 0;
foreach ($item->getUnits() as $unit) {
$promotionAmount = $splitPromotionAmount[$i++];
if (0 === $promotionAmount) {
continue;
}
$this->addAdjustment($promotion, $unit, $promotionAmount);
}
}
示例10:
function it_does_not_check_an_item_if_its_product_has_no_required_taxon(OrderInterface $order, OrderItemInterface $compositeBowItem, OrderItemInterface $longswordItem, ProductInterface $compositeBow, ProductInterface $longsword, TaxonInterface $bows, TaxonRepositoryInterface $taxonRepository)
{
$order->getItems()->willReturn(new \ArrayIterator([$compositeBowItem->getWrappedObject(), $longswordItem->getWrappedObject()]));
$taxonRepository->findOneBy(['code' => 'bows'])->willReturn($bows);
$compositeBowItem->getProduct()->willReturn($compositeBow);
$compositeBow->hasTaxon($bows)->willReturn(true);
$compositeBowItem->getQuantity()->willReturn(4);
$longswordItem->getProduct()->willReturn($longsword);
$longsword->hasTaxon($bows)->willReturn(false);
$longswordItem->getQuantity()->shouldNotBeCalled();
$this->isEligible($order, ['taxon' => 'bows', 'count' => 5])->shouldReturn(false);
}
示例11:
function it_recalculates_prices_adding_customer_to_the_context(ChannelInterface $channel, CustomerGroupInterface $group, CustomerInterface $customer, OrderInterface $order, OrderItemInterface $item, ProductVariantInterface $variant, ProductVariantPriceCalculatorInterface $productVariantPriceCalculator)
{
$order->getCustomer()->willReturn($customer);
$order->getChannel()->willReturn(null);
$order->getItems()->willReturn([$item]);
$order->getCurrencyCode()->willReturn(null);
$customer->getGroup()->willReturn($group);
$item->isImmutable()->willReturn(false);
$item->getQuantity()->willReturn(5);
$item->getVariant()->willReturn($variant);
$order->getChannel()->willReturn($channel);
$productVariantPriceCalculator->calculate($variant, ['channel' => $channel])->willReturn(10);
$item->setUnitPrice(10)->shouldBeCalled();
$this->process($order);
}
示例12: ArrayCollection
function it_holds_the_variant_stock_via_inventory_operator($inventoryOperator, $stateMachineFactory, OrderInterface $order, OrderItemInterface $item, ProductVariantInterface $variant, OrderItemUnitInterface $unit1, OrderItemUnitInterface $unit2, StateMachineInterface $sm1, StateMachineInterface $sm2)
{
$order->getItems()->willReturn([$item]);
$item->getVariant()->willReturn($variant);
$item->getQuantity()->willReturn(2);
$item->getUnits()->willReturn(new ArrayCollection([$unit1, $unit2]));
$stateMachineFactory->get($unit1, InventoryUnitTransitions::GRAPH)->willReturn($sm1);
$sm1->can(InventoryUnitTransitions::SYLIUS_HOLD)->willReturn(false);
$sm1->apply(InventoryUnitTransitions::SYLIUS_HOLD)->shouldNotBeCalled();
$stateMachineFactory->get($unit2, InventoryUnitTransitions::GRAPH)->willReturn($sm2);
$sm1->can(InventoryUnitTransitions::SYLIUS_HOLD)->willReturn(true);
$sm1->apply(InventoryUnitTransitions::SYLIUS_HOLD)->shouldBeCalled();
$inventoryOperator->hold($variant, 1)->shouldBeCalled();
$this->holdInventory($order);
}
示例13: processInventoryUnits
/**
* {@inheritdoc}
*/
public function processInventoryUnits(OrderItemInterface $item)
{
$nbUnits = $item->getInventoryUnits()->count();
if ($item->getQuantity() > $nbUnits) {
$this->createInventoryUnits($item, $item->getQuantity() - $nbUnits);
} elseif ($item->getQuantity() < $nbUnits) {
foreach ($item->getInventoryUnits()->slice(0, $nbUnits - $item->getQuantity()) as $unit) {
$item->removeInventoryUnit($unit);
}
}
foreach ($item->getInventoryUnits() as $unit) {
if ($unit->getStockable() !== $item->getVariant()) {
$unit->setStockable($item->getVariant());
}
}
}
示例14: array
function it_recalculates_prices_adding_all_context(GenericEvent $event, OrderInterface $order, OrderItemInterface $item, DelegatingCalculatorInterface $priceCalculator, GroupableInterface $customer, ArrayCollection $groups, ChannelInterface $channel, PriceableInterface $variant)
{
$event->getSubject()->shouldBeCalled()->willReturn($order);
$order->getCustomer()->shouldBeCalled()->willReturn($customer);
$order->getChannel()->shouldBeCalled()->willReturn($channel);
$order->getItems()->shouldBeCalled()->willReturn(array($item));
$order->calculateTotal()->shouldBeCalled();
$customer->getGroups()->shouldBeCalled()->willReturn($groups);
$groups->toArray()->shouldBeCalled()->willReturn(array('group1', 'group2'));
$item->isImmutable()->shouldBeCalled()->willReturn(false);
$item->getQuantity()->shouldBeCalled()->willReturn(5);
$item->setUnitPrice(10)->shouldBeCalled();
$item->getVariant()->shouldBeCalled()->willReturn($variant);
$priceCalculator->calculate($variant, array('customer' => $customer, 'groups' => array('group1', 'group2'), 'channel' => array($channel), 'quantity' => 5))->shouldBeCalled()->willReturn(10);
$this->recalculatePrices($event);
}
示例15:
function it_decreases_the_variant_stock_via_inventory_operator($inventoryOperator, $stateMachineFactory, OrderInterface $order, OrderItemInterface $item, ProductVariantInterface $variant, OrderItemUnitInterface $unit1, OrderItemUnitInterface $unit2, StateMachineInterface $sm1, StateMachineInterface $sm2)
{
$order->getItems()->willReturn([$item]);
$item->getVariant()->willReturn($variant);
$item->getQuantity()->willReturn(2);
$item->getUnits()->shouldBeCalled()->willReturn([$unit1, $unit2]);
$stateMachineFactory->get($unit1, InventoryUnitTransitions::GRAPH)->willReturn($sm1);
$sm1->can(InventoryUnitTransitions::SYLIUS_SELL)->willReturn(true);
$sm1->can(InventoryUnitTransitions::SYLIUS_RELEASE)->willReturn(true);
$sm1->apply(InventoryUnitTransitions::SYLIUS_SELL)->shouldBeCalled();
$stateMachineFactory->get($unit2, InventoryUnitTransitions::GRAPH)->willReturn($sm2);
$sm2->can(InventoryUnitTransitions::SYLIUS_SELL)->willReturn(true);
$sm2->can(InventoryUnitTransitions::SYLIUS_RELEASE)->willReturn(false);
$sm2->apply(InventoryUnitTransitions::SYLIUS_SELL)->shouldBeCalled();
$inventoryOperator->decrease([$unit1, $unit2])->shouldBeCalled();
$inventoryOperator->release($variant, 1)->shouldBeCalled();
$this->updateInventory($order);
}