@@ -57,21 +57,21 @@ public function run()
5757 return $ gaScripts ;
5858 }
5959
60- // Load up the order repository and try to find the order
60+ // Load up our handlers and repositories
6161 $ ganalyticsRepository = new GanalyticsRepository ();
62+ $ gaTagHandler = new GanalyticsJsHandler ($ this ->module , $ this ->context );
63+ $ productWrapper = new ProductWrapper ($ this ->context );
64+ $ orderWrapper = new OrderWrapper ($ this ->context );
65+
66+ // If the customer is revisiting confirmation screen and the order was already sent, we don't do anything
6267 if ($ ganalyticsRepository ->orderAlreadySent ((int ) $ order ->id )) {
6368 return $ gaScripts ;
6469 }
6570
6671 // Add order to repository, so we can later mark it as sent
67- // Repository inserts ignore, so no worries
72+ // If revisiting this page, repository inserts ignore, so no worries
6873 $ ganalyticsRepository ->addOrder ((int ) $ order ->id , (int ) $ order ->id_shop );
6974
70- // Load up our handlers
71- $ gaTagHandler = new GanalyticsJsHandler ($ this ->module , $ this ->context );
72- $ productWrapper = new ProductWrapper ($ this ->context );
73- $ orderWrapper = new OrderWrapper ($ this ->context );
74-
7575 // Prepare transaction data
7676 $ orderData = $ orderWrapper ->wrapOrder ((int ) $ order ->id );
7777
@@ -84,7 +84,7 @@ public function run()
8484 ]
8585 );
8686
87- // Prepare order products
87+ // Prepare order products, if the cart still exists
8888 $ orderProducts = [];
8989 $ cart = new Cart ($ order ->id_cart );
9090 if (Validate::isLoadedObject ($ cart )) {
0 commit comments