diff --git a/Config/module.xml b/Config/module.xml
index 93a2007..1e30f03 100644
--- a/Config/module.xml
+++ b/Config/module.xml
@@ -13,7 +13,7 @@
en_US
fr_FR
- 1.0.5
+ 1.0.7
mdevaud
diff --git a/EventListeners/OrderStatusListener.php b/EventListeners/OrderStatusListener.php
index 3785a0b..8200fb6 100644
--- a/EventListeners/OrderStatusListener.php
+++ b/EventListeners/OrderStatusListener.php
@@ -7,6 +7,7 @@
use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\OrderStatus;
+use Thelia\Model\OrderStatusQuery;
class OrderStatusListener implements EventSubscriberInterface
{
@@ -21,7 +22,6 @@ public function postOrderUpdate(OrderEvent $event){
if($this->subOrderService->isSubOrder($order->getId()) && $order->isPaid()){
$this->subOrderService->updateParentOrderStatus($order->getId(), OrderStatus::CODE_PAID);
}
-
}
public static function getSubscribedEvents()
diff --git a/Service/SubOrderService.php b/Service/SubOrderService.php
index 15ef78e..0fa21bf 100644
--- a/Service/SubOrderService.php
+++ b/Service/SubOrderService.php
@@ -6,11 +6,8 @@
use Exception;
use SubOrderGenerator\Model\SubOrder;
use SubOrderGenerator\Model\SubOrderQuery;
-use SubOrderGenerator\SubOrderGenerator;
use Thelia\Log\Tlog;
-use Thelia\Mailer\MailerFactory;
-use Thelia\Model\ConfigQuery;
use Thelia\Model\Map\OrderProductAttributeCombinationTableMap;
use Thelia\Model\Map\OrderProductTableMap;
use Thelia\Model\Map\OrderTableMap;
@@ -126,11 +123,13 @@ public function isSubOrder(int $orderId):bool {
public function updateParentOrderStatus(int $childOrderId, string $statusCode): Order
{
$orderStatus = OrderStatusQuery::create()->findOneByCode($statusCode);
- $parentOrder = SubOrderQuery::create()->findOneBySubOrderId($childOrderId)
- ->getOrderRelatedByParentOrderId();
- $parentOrder->setOrderStatus($orderStatus)
- ->save();
+ while(null !== $subOrder = SubOrderQuery::create()->findOneBySubOrderId($childOrderId)) {
+ $parentOrder = $subOrder->getOrderRelatedByParentOrderId();
+ $parentOrder->setOrderStatus($orderStatus)
+ ->save();
+ $childOrderId = $parentOrder->getId();
+ }
return $parentOrder;
}