diff --git a/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/OrderRepository.php b/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/OrderRepository.php index 0649870f35b..e20e9279af3 100644 --- a/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/OrderRepository.php +++ b/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/OrderRepository.php @@ -20,6 +20,7 @@ use Sylius\Component\Core\Model\ChannelInterface; use Sylius\Component\Core\Model\CustomerInterface; use Sylius\Component\Core\Model\OrderInterface; +use Sylius\Component\Order\Model\OrderInterface as BaseOrderInterface; use Sylius\Component\Core\Model\PromotionCouponInterface; use Sylius\Component\Core\OrderCheckoutStates; use Sylius\Component\Core\OrderPaymentStates; @@ -419,4 +420,16 @@ public function findCartForSelectingPayment($id): ?OrderInterface return $order; } + + public function findCartByTokenValue(string $tokenValue): ?BaseOrderInterface + { + return $this->createQueryBuilder('o') + ->andWhere('o.state = :state') + ->andWhere('o.tokenValue = :tokenValue') + ->setParameter('state', OrderInterface::STATE_CART) + ->setParameter('tokenValue', $tokenValue) + ->getQuery() + ->getOneOrNullResult() + ; + } } diff --git a/src/Sylius/Bundle/OrderBundle/Doctrine/ORM/OrderRepository.php b/src/Sylius/Bundle/OrderBundle/Doctrine/ORM/OrderRepository.php index 889988e4a1d..519d5de50a3 100644 --- a/src/Sylius/Bundle/OrderBundle/Doctrine/ORM/OrderRepository.php +++ b/src/Sylius/Bundle/OrderBundle/Doctrine/ORM/OrderRepository.php @@ -90,6 +90,7 @@ public function findOneByTokenValue(string $tokenValue): ?OrderInterface ; } + /** @deprecated since 1.9 and will be removed in Sylius 2.0, use src/Sylius/Bundle/CoreBundle/Doctrine/ORM/OrderRepositoryInterface instead */ public function findCartByTokenValue(string $tokenValue): ?OrderInterface { return $this->createQueryBuilder('o') diff --git a/src/Sylius/Component/Core/Repository/OrderRepositoryInterface.php b/src/Sylius/Component/Core/Repository/OrderRepositoryInterface.php index acf898010ba..a79b1fc5e19 100644 --- a/src/Sylius/Component/Core/Repository/OrderRepositoryInterface.php +++ b/src/Sylius/Component/Core/Repository/OrderRepositoryInterface.php @@ -17,6 +17,7 @@ use Sylius\Component\Core\Model\ChannelInterface; use Sylius\Component\Core\Model\CustomerInterface; use Sylius\Component\Core\Model\OrderInterface; +use Sylius\Component\Order\Model\OrderInterface as BaseOrderInterface; use Sylius\Component\Core\Model\PromotionCouponInterface; use Sylius\Component\Order\Repository\OrderRepositoryInterface as BaseOrderRepositoryInterface; @@ -81,4 +82,6 @@ public function findCartForAddressing($id): ?OrderInterface; public function findCartForSelectingShipping($id): ?OrderInterface; public function findCartForSelectingPayment($id): ?OrderInterface; + + public function findCartByTokenValue(string $tokenValue): ?BaseOrderInterface; } diff --git a/src/Sylius/Component/Order/Repository/OrderRepositoryInterface.php b/src/Sylius/Component/Order/Repository/OrderRepositoryInterface.php index d9a2efecedd..d54132840fd 100644 --- a/src/Sylius/Component/Order/Repository/OrderRepositoryInterface.php +++ b/src/Sylius/Component/Order/Repository/OrderRepositoryInterface.php @@ -32,6 +32,7 @@ public function findOneByNumber(string $number): ?OrderInterface; public function findOneByTokenValue(string $tokenValue): ?OrderInterface; + /** @deprecated since 1.9 and will be removed in Sylius 2.0, use src/Sylius/Bundle/CoreBundle/Doctrine/ORM/OrderRepositoryInterface instead */ public function findCartByTokenValue(string $tokenValue): ?OrderInterface; public function findCartById($id): ?OrderInterface;