@@ -61,14 +61,18 @@ discard block |
||
| 61 | 61 | $product = $orderProduct->getProduct(); |
| 62 | 62 | $productType = $product->getType(); |
| 63 | 63 | |
| 64 | - if (!in_array($productType, ['pruduct', 'service']) || $orderProduct->getId()) return $orderProduct; |
|
| 64 | + if (!in_array($productType, ['pruduct', 'service']) || $orderProduct->getId()) { |
|
| 65 | + return $orderProduct; |
|
| 66 | + } |
|
| 65 | 67 | |
| 66 | 68 | |
| 67 | 69 | $existOrderProduct = $this->manager->getRepository(OrderProduct::class)->findOneBy([ |
| 68 | 70 | 'product' => $product, |
| 69 | 71 | 'order' => $orderProduct->getOrder() |
| 70 | 72 | ]); |
| 71 | - if ($existOrderProduct) return $existOrderProduct->setQuantity($orderProduct->getQuantity()); |
|
| 73 | + if ($existOrderProduct) { |
|
| 74 | + return $existOrderProduct->setQuantity($orderProduct->getQuantity()); |
|
| 75 | + } |
|
| 72 | 76 | |
| 73 | 77 | |
| 74 | 78 | return $orderProduct; |
@@ -77,7 +81,9 @@ discard block |
||
| 77 | 81 | public function postPersist(OrderProduct $orderProduct) |
| 78 | 82 | { |
| 79 | 83 | |
| 80 | - if (!self::$mainProduct) return; |
|
| 84 | + if (!self::$mainProduct) { |
|
| 85 | + return; |
|
| 86 | + } |
|
| 81 | 87 | self::$mainProduct = false; |
| 82 | 88 | |
| 83 | 89 | $json = json_decode($this->request->getContent(), true); |
@@ -95,7 +101,9 @@ discard block |
||
| 95 | 101 | public function preRemove(OrderProduct $orderProduct) |
| 96 | 102 | { |
| 97 | 103 | |
| 98 | - if (!self::$mainProduct) return; |
|
| 104 | + if (!self::$mainProduct) { |
|
| 105 | + return; |
|
| 106 | + } |
|
| 99 | 107 | self::$mainProduct = false; |
| 100 | 108 | $order = $orderProduct->getOrder(); |
| 101 | 109 | $this->manager->persist($order->setPrice(0)); |
@@ -104,8 +112,9 @@ discard block |
||
| 104 | 112 | 'parentProduct' => $orderProduct->getProduct(), |
| 105 | 113 | ]); |
| 106 | 114 | |
| 107 | - foreach ($parentProducts as $parentProduct) |
|
| 108 | - $this->manager->remove($parentProduct); |
|
| 115 | + foreach ($parentProducts as $parentProduct) { |
|
| 116 | + $this->manager->remove($parentProduct); |
|
| 117 | + } |
|
| 109 | 118 | $this->manager->flush(); |
| 110 | 119 | |
| 111 | 120 | self::$calculateBefore[] = $order; |