本文整理汇总了PHP中Sylius\Component\Core\Model\OrderInterface::getChannel方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderInterface::getChannel方法的具体用法?PHP OrderInterface::getChannel怎么用?PHP OrderInterface::getChannel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Core\Model\OrderInterface
的用法示例。
在下文中一共展示了OrderInterface::getChannel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
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);
}
示例2: supports
/**
* {@inheritdoc}
*/
public function supports(OrderInterface $order, ZoneInterface $zone)
{
$channel = $order->getChannel();
/** @var ChannelInterface $channel */
Assert::isInstanceOf($channel, ChannelInterface::class);
return $channel->getTaxCalculationStrategy() === $this->type;
}
示例3: recalculate
/**
* {@inheritdoc}
*/
public function recalculate(OrderInterface $order)
{
$context = [];
if (null !== ($customer = $order->getCustomer())) {
$context['customer'] = $customer;
$context['groups'] = $customer->getGroups()->toArray();
}
if (null !== $order->getChannel()) {
$context['channel'] = [$order->getChannel()];
}
foreach ($order->getItems() as $item) {
if ($item->isImmutable()) {
continue;
}
$context['quantity'] = $item->getQuantity();
$item->setUnitPrice($this->priceCalculator->calculate($item->getVariant(), $context));
}
}
示例4:
function it_updates_order_exchange_rate(OrderInterface $order, CurrencyContextInterface $currencyContext, RepositoryInterface $currencyRepository, CurrencyInterface $currency, ChannelInterface $channel)
{
$order->getChannel()->willReturn($channel);
$currencyContext->getCurrencyCode()->willReturn('GBP');
$currencyRepository->findOneBy(['code' => 'GBP'])->willReturn($currency);
$currency->getExchangeRate()->willReturn(3.5);
$currency->getCode()->willReturn('GBP');
$order->setCurrencyCode('GBP')->shouldBeCalled();
$order->setExchangeRate(3.5)->shouldBeCalled();
$this->update($order);
}
示例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->recalculate($order);
}
示例6:
function it_cannot_be_supported_when_the_tax_calculation_strategy_from_order_channel_does_not_match_the_strategy_type(ChannelInterface $channel, OrderInterface $order, ZoneInterface $zone)
{
$order->getChannel()->willReturn($channel);
$channel->getTaxCalculationStrategy()->willReturn('order_item_units_based');
$this->supports($order, $zone)->shouldReturn(false);
}
示例7:
function it_provides_default_tax_zone_from_order_channel(ChannelInterface $channel, OrderInterface $order, ZoneInterface $defaultTaxZone)
{
$order->getChannel()->willReturn($channel);
$channel->getDefaultTaxZone()->willReturn($defaultTaxZone);
$this->getZone($order)->shouldReturn($defaultTaxZone);
}
示例8:
function it_returns_false_if_there_is_no_configuration_for_order_channel(ChannelInterface $channel, OrderInterface $order)
{
$order->getChannel()->willReturn($channel);
$channel->getCode()->willReturn('WEB_US');
$this->isEligible($order, [])->shouldReturn(false);
}
示例9: selectPayment
/**
* @param OrderInterface $order
*/
private function selectPayment(OrderInterface $order)
{
$paymentMethod = $this->faker->randomElement($order->getChannel()->getPaymentMethods()->toArray());
Assert::notNull($paymentMethod);
foreach ($order->getPayments() as $payment) {
$payment->setMethod($paymentMethod);
}
$this->applyCheckoutStateTransition($order, OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT);
}
示例10: selectPayment
/**
* @param OrderInterface $order
*/
private function selectPayment(OrderInterface $order)
{
$paymentMethod = $this->faker->randomElement($this->paymentMethodRepository->findEnabledForChannel($order->getChannel()));
Assert::notNull($paymentMethod, 'Payment method should not be null.');
foreach ($order->getPayments() as $payment) {
$payment->setMethod($paymentMethod);
}
$this->applyCheckoutStateTransition($order, OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT);
}
示例11:
function it_does_not_apply_discount_if_percentage_configuration_not_defined(ChannelInterface $channel, OrderInterface $order, PromotionInterface $promotion)
{
$order->getChannel()->willReturn($channel);
$channel->getCode()->willReturn('WEB_PL');
$order->getItems()->shouldNotBeCalled();
$this->execute($order, ['WEB_PL' => []], $promotion)->shouldReturn(false);
}
示例12:
function it_returns_false_if_taxon_with_configured_code_cannot_be_found(ChannelInterface $channel, OrderInterface $order, TaxonRepositoryInterface $taxonRepository)
{
$order->getChannel()->willReturn($channel);
$channel->getCode()->willReturn('WEB_US');
$taxonRepository->findOneBy(['code' => 'sniper_rifles'])->willReturn(null);
$this->isEligible($order, ['WEB_US' => ['taxon' => 'sniper_rifles', 'amount' => 1000]])->shouldReturn(false);
}
示例13:
function it_does_not_apply_discount_if_configuration_is_invalid(ChannelInterface $channel, OrderInterface $order, PromotionInterface $promotion)
{
$order->getChannel()->willReturn($channel, $channel);
$channel->getCode()->willReturn('WEB_US', 'WEB_US');
$order->countItems()->willReturn(1, 1);
$this->execute($order, ['WEB_US' => []], $promotion)->shouldReturn(false);
$this->execute($order, ['WEB_US' => ['amount' => 'string']], $promotion)->shouldReturn(false);
}
示例14: ArrayCollection
function it_reverts_a_proper_promotion_adjustment_from_all_units(AdjustmentInterface $promotionAdjustment1, AdjustmentInterface $promotionAdjustment2, ChannelInterface $channel, OrderInterface $order, OrderItemInterface $orderItem, OrderItemUnitInterface $unit, PromotionInterface $promotion)
{
$order->getChannel()->willReturn($channel);
$channel->getCode()->willReturn('WEB_US');
$order->getItems()->willReturn(new ArrayCollection([$orderItem->getWrappedObject()]));
$orderItem->getUnits()->willReturn(new ArrayCollection([$unit->getWrappedObject()]));
$unit->getAdjustments(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT)->willReturn(new ArrayCollection([$promotionAdjustment1->getWrappedObject(), $promotionAdjustment2->getWrappedObject()]));
$promotion->getCode()->willReturn('PROMOTION');
$promotionAdjustment1->getOriginCode()->willReturn('PROMOTION');
$unit->removeAdjustment($promotionAdjustment1)->shouldBeCalled();
$promotionAdjustment2->getOriginCode()->willReturn('OTHER_PROMOTION');
$unit->removeAdjustment($promotionAdjustment2)->shouldNotBeCalled();
$this->revert($order, ['WEB_US' => ['amount' => 1000]], $promotion);
}
示例15:
function it_provides_active_promotions_for_given_subject_channel($promotionRepository, ChannelInterface $channel, PromotionInterface $promotion1, PromotionInterface $promotion2, OrderInterface $subject)
{
$subject->getChannel()->willReturn($channel);
$promotionRepository->findActiveByChannel($channel)->willReturn([$promotion1, $promotion2]);
$this->getPromotions($subject)->shouldReturn([$promotion1, $promotion2]);
}