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


PHP OrderInterface::addAdjustment方法代码示例

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


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

示例1: addAdjustmentIfForNotCancelled

 /**
  * @param OrderInterface   $order
  * @param PaymentSubjectInterface $payment
  */
 private function addAdjustmentIfForNotCancelled(OrderInterface $order, PaymentSubjectInterface $payment)
 {
     if (PaymentInterface::STATE_CANCELLED !== $payment->getState())
     {
         $order->addAdjustment($this->prepareAdjustmentForOrder($payment));
     }
 }
开发者ID:kriswillis,项目名称:Sylius,代码行数:11,代码来源:PaymentChargesProcessor.php

示例2:

    function it_applies_payment_charges(
        $adjustmentRepository,
        $delegatingFeeCalculator,
        AdjustmentInterface $adjustment,
        OrderInterface $order,
        PaymentSubjectInterface $payment,
        PaymentMethodInterface $paymentMethod
    ) {
        $order->removeAdjustments('payment')->shouldBeCalled();
        $order->getPayments()->willReturn(array($payment))->shouldBeCalled();

        $order->calculateTotal()->shouldBeCalled();

        $payment->getState()->willReturn('new')->shouldBeCalled();
        $payment->getMethod()->willReturn($paymentMethod);
        $paymentMethod->getName()->willReturn('testPaymentMethod');

        $delegatingFeeCalculator->calculate($payment)->willReturn(50);

        $adjustmentRepository->createNew()->willReturn($adjustment)->shouldBeCalled();
        $adjustment->setType('payment')->shouldBeCalled();
        $adjustment->setAmount(50)->shouldBeCalled();
        $adjustment->setDescription('testPaymentMethod')->shouldBeCalled();

        $order->addAdjustment($adjustment)->shouldBeCalled();

        $this->applyPaymentCharges($order);
    }
开发者ID:kriswillis,项目名称:Sylius,代码行数:28,代码来源:PaymentChargesProcessorSpec.php

示例3:

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

示例4: array

 function it_applies_fixed_discount_as_promotion_adjustment($adjustmentRepository, OrderInterface $order, AdjustmentInterface $adjustment, PromotionInterface $promotion)
 {
     $adjustmentRepository->createNew()->willReturn($adjustment);
     $promotion->getDescription()->willReturn('promotion description');
     $adjustment->setAmount(-500)->shouldBeCalled();
     $adjustment->setLabel(OrderInterface::PROMOTION_ADJUSTMENT)->shouldBeCalled();
     $adjustment->setDescription('promotion description')->shouldBeCalled();
     $order->addAdjustment($adjustment)->shouldBeCalled();
     $configuration = array('amount' => 500);
     $this->execute($order, $configuration, $promotion);
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:11,代码来源:FixedDiscountActionSpec.php

示例5:

 function it_does_nothing_if_there_are_no_shipment_taxes_on_order($adjustmentsFactory, $calculator, $taxRateResolver, Collection $shippingAdjustments, OrderInterface $order, ShipmentInterface $shipment, ShippingMethodInterface $shippingMethod, TaxRateInterface $taxRate, ZoneInterface $zone)
 {
     $order->getLastShipment()->willReturn($shipment);
     $shipment->getMethod()->willReturn($shippingMethod);
     $taxRateResolver->resolve($shippingMethod, ['zone' => $zone])->willReturn($taxRate);
     $order->getAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT)->willReturn($shippingAdjustments);
     $shippingAdjustments->isEmpty()->willReturn(false);
     $order->getShippingTotal()->willReturn(1000);
     $calculator->calculate(1000, $taxRate)->willReturn(0);
     $adjustmentsFactory->createWithData(Argument::cetera())->shouldNotBeCalled();
     $order->addAdjustment(Argument::any())->shouldNotBeCalled();
     $this->apply($order, $zone);
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:13,代码来源:OrderShipmentTaxesApplicatorSpec.php

示例6: array

 function it_applies_percentage_discount_as_promotion_adjustment($adjustmentRepository, $originator, OrderInterface $order, AdjustmentInterface $adjustment, PromotionInterface $promotion)
 {
     $order->getPromotionSubjectTotal()->willReturn(10000);
     $adjustmentRepository->createNew()->willReturn($adjustment);
     $promotion->getDescription()->willReturn('promotion description');
     $adjustment->setAmount(-2500)->shouldBeCalled();
     $adjustment->setLabel(AdjustmentInterface::PROMOTION_ADJUSTMENT)->shouldBeCalled();
     $adjustment->setDescription('promotion description')->shouldBeCalled();
     $originator->setOrigin($adjustment, $promotion)->shouldBeCalled();
     $order->addAdjustment($adjustment)->shouldBeCalled();
     $configuration = array('percentage' => 0.25);
     $this->execute($order, $configuration, $promotion);
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:13,代码来源:PercentageDiscountActionSpec.php

示例7: applyShippingCharges

 /**
  * {@inheritdoc}
  */
 public function applyShippingCharges(OrderInterface $order)
 {
     // Remove all shipping adjustments, we recalculate everything from scratch.
     $order->removeAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT);
     foreach ($order->getShipments() as $shipment) {
         $shippingCharge = $this->calculator->calculate($shipment);
         $adjustment = $this->adjustmentFactory->createNew();
         $adjustment->setType(AdjustmentInterface::SHIPPING_ADJUSTMENT);
         $adjustment->setAmount($shippingCharge);
         $adjustment->setDescription($shipment->getMethod()->getName());
         $order->addAdjustment($adjustment);
     }
 }
开发者ID:benakacha,项目名称:Sylius,代码行数:16,代码来源:ShippingChargesProcessor.php

示例8:

 function it_does_not_applies_bigger_discount_than_promotion_subject_total($adjustmentFactory, $originator, OrderInterface $order, AdjustmentInterface $adjustment, PromotionInterface $promotion)
 {
     $adjustmentFactory->createNew()->willReturn($adjustment);
     $promotion->getDescription()->willReturn('promotion description');
     $order->getPromotionSubjectTotal()->willReturn(1000);
     $adjustment->setAmount(-1000)->shouldBeCalled();
     $adjustment->setType(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->shouldBeCalled();
     $adjustment->setLabel('promotion description')->shouldBeCalled();
     $originator->setOrigin($adjustment, $promotion)->shouldBeCalled();
     $order->addAdjustment($adjustment)->shouldBeCalled();
     $configuration = ['amount' => 1500];
     $this->execute($order, $configuration, $promotion);
 }
开发者ID:Mozan,项目名称:Sylius,代码行数:13,代码来源:FixedDiscountActionSpec.php

示例9:

 function it_applies_percentage_discount_as_promotion_adjustment(FactoryInterface $adjustmentFactory, $originator, OrderInterface $order, AdjustmentInterface $adjustment, PromotionInterface $promotion)
 {
     $order->getPromotionSubjectTotal()->willReturn(10000);
     $adjustmentFactory->createNew()->willReturn($adjustment);
     $promotion->getName()->willReturn('Test promotion');
     $adjustment->setAmount(-2500)->shouldBeCalled();
     $adjustment->setType(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->shouldBeCalled();
     $adjustment->setLabel('Test promotion')->shouldBeCalled();
     $originator->setOrigin($adjustment, $promotion)->shouldBeCalled();
     $order->addAdjustment($adjustment)->shouldBeCalled();
     $configuration = ['percentage' => 0.25];
     $this->execute($order, $configuration, $promotion);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:13,代码来源:PercentageDiscountActionSpec.php

示例10:

 function it_applies_calculated_shipping_charge_for_each_shipment_associated_with_the_order(FactoryInterface $adjustmentFactory, DelegatingCalculatorInterface $calculator, AdjustmentInterface $adjustment, OrderInterface $order, ShipmentInterface $shipment, ShippingMethodInterface $shippingMethod)
 {
     $adjustmentFactory->createNew()->willReturn($adjustment);
     $order->getShipments()->willReturn([$shipment]);
     $calculator->calculate($shipment)->willReturn(450);
     $shipment->getMethod()->willReturn($shippingMethod);
     $shippingMethod->getName()->willReturn('FedEx');
     $adjustment->setAmount(450)->shouldBeCalled();
     $adjustment->setType(AdjustmentInterface::SHIPPING_ADJUSTMENT)->shouldBeCalled();
     $adjustment->setLabel('FedEx')->shouldBeCalled();
     $order->removeAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT)->shouldBeCalled();
     $order->addAdjustment($adjustment)->shouldBeCalled();
     $this->process($order);
 }
开发者ID:origammi,项目名称:Sylius,代码行数:14,代码来源:ShippingChargesProcessorSpec.php

示例11:

 function it_applies_calculated_shipping_charge_for_each_shipment_associated_with_the_order($adjustmentRepository, $calculator, AdjustmentInterface $adjustment, OrderInterface $order, ShipmentInterface $shipment, ShippingMethodInterface $shippingMethod)
 {
     $adjustmentRepository->createNew()->willReturn($adjustment);
     $order->getShipments()->willReturn(array($shipment));
     $calculator->calculate($shipment)->willReturn(450);
     $shipment->getMethod()->willReturn($shippingMethod);
     $shippingMethod->getName()->willReturn('FedEx');
     $adjustment->setAmount(450)->shouldBeCalled();
     $adjustment->setLabel(Order::SHIPPING_ADJUSTMENT)->shouldBeCalled();
     $adjustment->setDescription('FedEx')->shouldBeCalled();
     $order->removeShippingAdjustments()->shouldBeCalled();
     $order->addAdjustment($adjustment)->shouldBeCalled();
     $order->calculateTotal()->shouldBeCalled();
     $this->applyShippingCharges($order);
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:15,代码来源:ShippingChargesProcessorSpec.php

示例12: array

 function it_applies_shipment_taxes_on_order_based_on_shipment_adjustments_and_rate($adjustmentsFactory, $calculator, $taxRateResolver, AdjustmentInterface $shippingAdjustment, AdjustmentInterface $shippingTaxAdjustment, Collection $shippingAdjustments, OrderInterface $order, ShipmentInterface $shipment, ShippingMethodInterface $shippingMethod, TaxRateInterface $taxRate, ZoneInterface $zone)
 {
     $order->getLastShipment()->willReturn($shipment);
     $shipment->getMethod()->willReturn($shippingMethod);
     $taxRateResolver->resolve($shippingMethod, array('zone' => $zone))->willReturn($taxRate);
     $taxRate->getLabel()->willReturn('Simple tax (10%)');
     $taxRate->isIncludedInPrice()->willReturn(false);
     $order->getAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT)->willReturn($shippingAdjustments);
     $shippingAdjustments->isEmpty()->willReturn(false);
     $shippingAdjustments->last()->willReturn($shippingAdjustment);
     $shippingAdjustment->getAmount()->willReturn(1000);
     $calculator->calculate(1000, $taxRate)->willReturn(100);
     $adjustmentsFactory->createWithData(AdjustmentInterface::TAX_ADJUSTMENT, 'Simple tax (10%)', 100, false)->willReturn($shippingTaxAdjustment);
     $order->addAdjustment($shippingTaxAdjustment)->shouldBeCalled();
     $this->apply($order, $zone);
 }
开发者ID:sidibea,项目名称:Sylius,代码行数:16,代码来源:OrderShipmentTaxesByZoneApplicatorSpec.php

示例13: process

 /**
  * {@inheritdoc}
  */
 public function process(OrderInterface $order)
 {
     // Remove all shipping adjustments, we recalculate everything from scratch.
     $order->removeAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT);
     foreach ($order->getShipments() as $shipment) {
         try {
             $shippingCharge = $this->shippingChargesCalculator->calculate($shipment);
             $adjustment = $this->adjustmentFactory->createNew();
             $adjustment->setType(AdjustmentInterface::SHIPPING_ADJUSTMENT);
             $adjustment->setAmount($shippingCharge);
             $adjustment->setLabel($shipment->getMethod()->getName());
             $order->addAdjustment($adjustment);
         } catch (UndefinedShippingMethodException $exception) {
         }
     }
 }
开发者ID:origammi,项目名称:Sylius,代码行数:19,代码来源:ShippingChargesProcessor.php

示例14: addAdjustment

 /**
  * @param OrderInterface $order
  * @param int $taxAmount
  * @param string $label
  * @param bool $included
  */
 private function addAdjustment($order, $taxAmount, $label, $included)
 {
     /** @var AdjustmentInterface $shippingTaxAdjustment */
     $shippingTaxAdjustment = $this->adjustmentFactory->createWithData(AdjustmentInterface::TAX_ADJUSTMENT, $label, $taxAmount, $included);
     $order->addAdjustment($shippingTaxAdjustment);
 }
开发者ID:rpg600,项目名称:Sylius,代码行数:12,代码来源:OrderShipmentTaxesApplicator.php

示例15: addAdjustments

 private function addAdjustments(array $taxes, OrderInterface $order)
 {
     foreach ($taxes as $description => $tax) {
         $adjustment = $this->adjustmentRepository->createNew();
         $adjustment->setLabel(AdjustmentInterface::TAX_ADJUSTMENT);
         $adjustment->setAmount($tax['amount']);
         $adjustment->setDescription($description);
         $adjustment->setNeutral($tax['included']);
         $order->addAdjustment($adjustment);
     }
 }
开发者ID:Avazanga1,项目名称:Sylius,代码行数:11,代码来源:TaxationProcessor.php


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