本文整理匯總了PHP中Sylius\Component\Core\Model\OrderInterface::getItems方法的典型用法代碼示例。如果您正苦於以下問題:PHP OrderInterface::getItems方法的具體用法?PHP OrderInterface::getItems怎麽用?PHP OrderInterface::getItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sylius\Component\Core\Model\OrderInterface
的用法示例。
在下文中一共展示了OrderInterface::getItems方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1:
function it_returns_false_if_variant_is_not_included_and_exclude_is_not_set(OrderInterface $subject, OrderItem $orderItem, ProductVariant $variant)
{
$subject->getItems()->willReturn([$orderItem]);
$orderItem->getVariant()->willReturn($variant);
$variant->getId()->willReturn(2);
$this->isEligible($subject, ['variant' => 1, 'exclude' => false])->shouldReturn(false);
}
示例2: holdInventory
/**
* {@inheritdoc}
*/
public function holdInventory(OrderInterface $order)
{
foreach ($order->getItems() as $item) {
$quantity = $this->applyTransition($item->getUnits(), InventoryUnitTransitions::SYLIUS_HOLD);
$this->inventoryOperator->hold($item->getVariant(), $quantity);
}
}
示例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: decreaseSoldVariants
/**
* @param OrderInterface $order
*/
public function decreaseSoldVariants(OrderInterface $order)
{
/** @var $item OrderItemInterface */
foreach ($order->getItems() as $item) {
$variant = $item->getVariant();
$variant->setSold($variant->getSold() - $item->getQuantity());
}
}
示例5:
function it_returns_false_if_variant_is_included_and_count_is_set_bigger_amount_than_quantity(OrderInterface $subject, OrderItem $orderItem, ProductVariant $variant)
{
$subject->getItems()->willReturn([$orderItem]);
$orderItem->getVariant()->willReturn($variant);
$variant->getId()->willReturn(1);
$orderItem->getPromotionSubjectCount()->willReturn(1);
$this->isEligible($subject, ['variant' => 1, 'exclude' => false, 'count' => 2])->shouldReturn(false);
}
示例6:
function it_returns_false_if_product_is_wrong(OrderInterface $subject, OrderItemInterface $firstOrderItem, OrderItemInterface $secondOrderItem, ProductInterface $shaft, ProductInterface $head)
{
$subject->getItems()->willReturn([$firstOrderItem, $secondOrderItem]);
$firstOrderItem->getProduct()->willReturn($head);
$secondOrderItem->getProduct()->willReturn($shaft);
$head->getCode()->willReturn('LACROSSE_HEAD');
$shaft->getCode()->willReturn('LACROSSE_SHAFT');
$this->isEligible($subject, ['product_code' => 'LACROSSE_STRING'])->shouldReturn(false);
}
示例7:
function it_doesnt_apply_any_taxes_if_zone_is_missing(OrderInterface $order, Collection $collection, $taxationSettings)
{
$collection->isEmpty()->willReturn(false);
$order->getItems()->willReturn($collection);
$order->removeTaxAdjustments()->shouldBeCalled();
$order->getShippingAddress()->willReturn(null);
$taxationSettings->has('default_tax_zone')->willReturn(false);
$order->addAdjustment(Argument::any())->shouldNotBeCalled();
$this->applyTaxes($order);
}
示例8:
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]);
}
示例9:
function it_should_recognize_subject_as_not_eligible_if_product_taxonomy_is_matched_and_exclude_is_set(OrderInterface $subject, OrderItemInterface $item, Taxon $taxon, Product $product, ArrayCollection $collection)
{
$configuration = ['taxons' => $collection, 'exclude' => true];
$collection->contains(2)->willReturn(true);
$taxon->getId()->willReturn(2);
$product->getTaxons()->willReturn([$taxon]);
$item->getProduct()->willReturn($product);
$subject->getItems()->willReturn([$item]);
$this->isEligible($subject, $configuration)->shouldReturn(false);
}
示例10: decrease
/**
* {@inheritdoc}
*/
public function decrease(OrderInterface $order)
{
/** @var OrderItemInterface $orderItem */
foreach ($order->getItems() as $orderItem) {
$variant = $orderItem->getVariant();
if ($variant->isTracked()) {
Assert::greaterThanEq($variant->getOnHold() - $orderItem->getQuantity(), 0, sprintf('Not enough units to decrease the inventory of a variant "%s".', $variant->getName()));
$variant->setOnHold($variant->getOnHold() - $orderItem->getQuantity());
}
}
}
示例11: giveBack
/**
* @param OrderInterface $order
*/
private function giveBack(OrderInterface $order)
{
/** @var OrderItemInterface $orderItem */
foreach ($order->getItems() as $orderItem) {
$variant = $orderItem->getVariant();
if (!$variant->isTracked()) {
continue;
}
$variant->setOnHand($variant->getOnHand() + $orderItem->getQuantity());
}
}
示例12: apply
/**
* {@inheritdoc}
*/
public function apply(OrderInterface $order, PromotionInterface $promotion, array $adjustmentsAmounts)
{
Assert::eq($order->countItems(), count($adjustmentsAmounts));
$i = 0;
foreach ($order->getItems() as $item) {
$adjustmentAmount = $adjustmentsAmounts[$i++];
if (0 === $adjustmentAmount) {
continue;
}
$this->applyAdjustmentsOnItemUnits($item, $promotion, $adjustmentAmount);
}
}
示例13:
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);
}
示例14:
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);
}
示例15:
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);
}