/** * {@inheritdoc} */ public function removeAdjustment(AdjustmentInterface $adjustment) { if ($adjustment->isLocked() || !$this->hasAdjustment($adjustment)) { return; } $this->adjustments->removeElement($adjustment); $this->subtractFromAdjustmentsTotal($adjustment); $this->orderItem->recalculateUnitsTotal(); $adjustment->setAdjustable(null); }
function it_recalculates_its_total_properly_after_adjustment_amount_change(AdjustmentInterface $adjustment1, AdjustmentInterface $adjustment2, OrderItemInterface $orderItem) { $orderItem->recalculateUnitsTotal()->shouldBeCalledTimes(2); $adjustment1->isNeutral()->willReturn(false); $adjustment1->setAdjustable($this)->shouldBeCalled(); $adjustment1->getAmount()->willReturn(100); $adjustment2->isNeutral()->willReturn(false); $adjustment2->setAdjustable($this)->shouldBeCalled(); $adjustment2->getAmount()->willReturn(50); $this->addAdjustment($adjustment1); $this->addAdjustment($adjustment2); $adjustment2->getAmount()->willReturn(150); $this->recalculateAdjustmentsTotal(); $this->getTotal()->shouldReturn(1250); }
/** * {@inheritdoc} */ public function clearAdjustments() { $this->adjustments->clear(); $this->recalculateAdjustmentsTotal(); $this->orderItem->recalculateUnitsTotal(); }