当前位置: 首页>>代码示例>>PHP>>正文


PHP OrderItemInterface::getVariant方法代码示例

本文整理汇总了PHP中Sylius\Component\Core\Model\OrderItemInterface::getVariant方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderItemInterface::getVariant方法的具体用法?PHP OrderItemInterface::getVariant怎么用?PHP OrderItemInterface::getVariant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sylius\Component\Core\Model\OrderItemInterface的用法示例。


在下文中一共展示了OrderItemInterface::getVariant方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 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);
 }
开发者ID:TheMadeleine,项目名称:Sylius,代码行数:27,代码来源:ConvertPaymentActionSpec.php

示例2:

 function it_filters_items_which_has_product_with_price_equal_to_configured_minimum_criteria(ChannelInterface $channel, OrderItemInterface $item1, OrderItemInterface $item2, ProductVariantInterface $item1Variant, ProductVariantInterface $item2Variant, ProductVariantPriceCalculatorInterface $productVariantPriceCalculator)
 {
     $item1->getVariant()->willReturn($item1Variant);
     $item2->getVariant()->willReturn($item2Variant);
     $productVariantPriceCalculator->calculate($item1Variant, ['channel' => $channel])->willReturn(500);
     $productVariantPriceCalculator->calculate($item2Variant, ['channel' => $channel])->willReturn(1000);
     $this->filter([$item1, $item2], ['filters' => ['price_range_filter' => ['min' => 1000]], 'channel' => $channel])->shouldReturn([$item2]);
 }
开发者ID:sylius,项目名称:core,代码行数:8,代码来源:PriceRangeFilterSpec.php

示例3:

 function it_filters_items_which_has_product_with_price_equal_to_configured_minimum_criteria(OrderItemInterface $item1, OrderItemInterface $item2, ProductVariantInterface $item1Variant, ProductVariantInterface $item2Variant)
 {
     $item1->getVariant()->willReturn($item1Variant);
     $item2->getVariant()->willReturn($item2Variant);
     $item1Variant->getPrice()->willReturn(500);
     $item2Variant->getPrice()->willReturn(1000);
     $this->filter([$item1, $item2], ['filters' => ['price_range' => ['min' => 1000]]])->shouldReturn([$item2]);
 }
开发者ID:TheMadeleine,项目名称:Sylius,代码行数:8,代码来源:PriceRangeFilterSpec.php

示例4:

 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]);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:10,代码来源:OnHandQuantityUpdaterSpec.php

示例5:

 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);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:12,代码来源:OrderPricesRecalculatorSpec.php

示例6: 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);
 }
开发者ID:TeamNovatek,项目名称:Sylius,代码行数:15,代码来源:InventoryHandlerSpec.php

示例7:

 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);
 }
开发者ID:sylius,项目名称:core,代码行数:15,代码来源:OrderPricesRecalculatorSpec.php

示例8: 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);
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:16,代码来源:OrderPricingListenerSpec.php

示例9:

 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);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:18,代码来源:InventoryHandlerSpec.php

示例10: createInventoryUnits

 protected function createInventoryUnits(OrderItemInterface $item, $quantity, $state = InventoryUnitInterface::STATE_CHECKOUT)
 {
     $units = $this->inventoryUnitFactory->create($item->getVariant(), $quantity, $state);
     foreach ($units as $unit) {
         $item->addInventoryUnit($unit);
     }
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:7,代码来源:InventoryHandler.php

示例11:

 function it_does_nothing_if_variant_is_not_tracked_during_selling(OrderInterface $order, OrderItemInterface $orderItem, ProductVariantInterface $variant)
 {
     $order->getItems()->willReturn([$orderItem]);
     $orderItem->getVariant()->willReturn($variant);
     $variant->isTracked()->willReturn(false);
     $variant->setOnHold(Argument::any())->shouldNotBeCalled();
     $variant->setOnHand(Argument::any())->shouldNotBeCalled();
     $this->sell($order);
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:9,代码来源:OrderInventoryOperatorSpec.php

示例12:

 function its_shippable_is_an_order_item_variant(OrderItemInterface $orderItem, ProductVariantInterface $variant)
 {
     $orderItem->getVariant()->willReturn($variant);
     $this->getShippable()->shouldReturn($variant);
 }
开发者ID:TheMadeleine,项目名称:Sylius,代码行数:5,代码来源:OrderItemUnitSpec.php

示例13:

 function it_does_not_apply_taxes_with_amount_0(CalculatorInterface $calculator, AdjustmentFactoryInterface $adjustmentsFactory, TaxRateResolverInterface $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(2);
     $items->getIterator()->willReturn(new \ArrayIterator([$orderItem->getWrappedObject()]));
     $orderItem->getQuantity()->willReturn(2);
     $orderItem->getVariant()->willReturn($productVariant);
     $taxRateResolver->resolve($productVariant, ['zone' => $zone])->willReturn($taxRate);
     $orderItem->getUnits()->willReturn($units);
     $units->getIterator()->willReturn(new \ArrayIterator([$unit1->getWrappedObject(), $unit2->getWrappedObject()]));
     $unit1->getTotal()->willReturn(1000);
     $calculator->calculate(1000, $taxRate)->willReturn(0);
     $unit2->getTotal()->willReturn(900);
     $calculator->calculate(900, $taxRate)->willReturn(0);
     $adjustmentsFactory->createWithData(AdjustmentInterface::TAX_ADJUSTMENT, Argument::cetera())->shouldNotBeCalled();
     $unit1->addAdjustment(Argument::any())->shouldNotBeCalled();
     $unit2->addAdjustment(Argument::any())->shouldNotBeCalled();
     $this->apply($order, $zone);
 }
开发者ID:TheMadeleine,项目名称:Sylius,代码行数:19,代码来源:OrderItemUnitsTaxesApplicatorSpec.php

示例14: 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);
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:18,代码来源:OrderItemsTaxesApplicatorSpec.php

示例15:

 function it_throws_invalid_argument_exception_if_on_hold_quantity_to_decrease_will_be_below_zero(OrderInterface $order, OrderItemInterface $orderItem, ProductVariantInterface $productVariant)
 {
     $productVariant->getOnHold()->willReturn(5);
     $productVariant->isTracked()->willReturn(true);
     $productVariant->getName()->willReturn('t-shirt');
     $orderItem->getVariant()->willReturn($productVariant);
     $orderItem->getQuantity()->willReturn(10);
     $order->getItems()->willReturn([$orderItem]);
     $productVariant->setOnHold(-5)->shouldNotBeCalled();
     $this->shouldThrow(\InvalidArgumentException::class)->during('decrease', [$order]);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:11,代码来源:OnHoldQuantityUpdaterSpec.php


注:本文中的Sylius\Component\Core\Model\OrderItemInterface::getVariant方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。