Determine Order being processable on itself

This commit is contained in:
Mateusz Zalewski 2023-04-13 16:52:43 +02:00
parent 1d85b6a08e
commit c19bb1d15b
No known key found for this signature in database
GPG key ID: 9BECA0BB71612E52
3 changed files with 18 additions and 0 deletions

View file

@ -832,4 +832,15 @@ final class OrderSpec extends ObjectBehavior
$this->getTaxIncludedTotal()->shouldReturn(1500);
$this->getTaxExcludedTotal()->shouldReturn(800);
}
function it_can_be_processed(): void
{
$this->setState(OrderInterface::STATE_CART);
$this->canBeProcessed()->shouldReturn(true);
$this->setState(OrderInterface::STATE_NEW);
$this->canBeProcessed()->shouldReturn(false);
}
}

View file

@ -315,6 +315,11 @@ class Order implements OrderInterface
$this->recalculateTotal();
}
public function canBeProcessed(): bool
{
return $this->state === self::STATE_CART;
}
/**
* Items total + Adjustments total.
*/

View file

@ -84,4 +84,6 @@ interface OrderInterface extends AdjustableInterface, ResourceInterface, Timesta
public function getAdjustmentsTotalRecursively(?string $type = null): int;
public function removeAdjustmentsRecursively(?string $type = null): void;
public function canBeProcessed(): bool;
}