← All changes
|
src/Controllers/Hooks/Order/class-order-controller.php
+21
-2
3.2.1
→
4.3.0
View file →
| @@ -9,9 +9,10 @@ | ||
| 9 | 9 | namespace SeQura\WC\Controllers\Hooks\Order; |
| 10 | 10 | |
| 11 | 11 | use SeQura\Core\Infrastructure\Logger\LogContextData; |
| 12 | 12 | use SeQura\WC\Controllers\Controller; |
| 13 | -use SeQura\WC\Services\Interface_Logger_Service; | |
| 13 | +use SeQura\WC\Services\Cart\Interface_Cart_Service; | |
| 14 | +use SeQura\WC\Services\Log\Interface_Logger_Service; | |
| 14 | 15 | use SeQura\WC\Services\Order\Interface_Order_Service; |
| 15 | 16 | use Throwable; |
| 16 | 17 | use WC_Order; |
| 17 | 18 | |
| @@ -27,17 +28,26 @@ | ||
| 27 | 28 | */ |
| 28 | 29 | private $order_service; |
| 29 | 30 | |
| 30 | 31 | /** |
| 32 | + * Cart service | |
| 33 | + * | |
| 34 | + * @var Interface_Cart_Service | |
| 35 | + */ | |
| 36 | + private $cart_service; | |
| 37 | + | |
| 38 | + /** | |
| 31 | 39 | * Constructor |
| 32 | 40 | */ |
| 33 | 41 | public function __construct( |
| 34 | 42 | Interface_Logger_Service $logger, |
| 35 | 43 | string $templates_path, |
| 36 | - Interface_Order_Service $order_service | |
| 44 | + Interface_Order_Service $order_service, | |
| 45 | + Interface_Cart_Service $cart_service | |
| 37 | 46 | ) { |
| 38 | 47 | parent::__construct( $logger, $templates_path ); |
| 39 | 48 | $this->order_service = $order_service; |
| 49 | + $this->cart_service = $cart_service; | |
| 40 | 50 | |
| 41 | 51 | \add_action( 'admin_notices', array( $this, 'display_notices' ) ); |
| 42 | 52 | } |
| 43 | 53 | |
| @@ -183,6 +193,15 @@ | ||
| 183 | 193 | return; |
| 184 | 194 | } |
| 185 | 195 | |
| 186 | 196 | $this->order_service->migrate_data(); |
| 197 | + } | |
| 198 | + | |
| 199 | + /** | |
| 200 | + * Create the Cart Info object for the current session if it doesn't exist. | |
| 201 | + * | |
| 202 | + * @return void | |
| 203 | + */ | |
| 204 | + public function ensure_cart_info_exists() { | |
| 205 | + $this->cart_service->get_cart_info_from_session(); | |
| 187 | 206 | } |
| 188 | 207 | } |