@@ -190,22 +190,29 @@ public function orderDataSend($order): array
190190 try {
191191 $ connectionId = $ this ->activeCampaignHelper ->getConnectionId ($ order ->getStoreId ());
192192 $ customerId = $ order ->getCustomerId ();
193- $ customerAcId = 0 ;
194- $ quote = $ this ->quoteRepository ->get ($ order ->getQuoteId ());
193+ $ quoteModel = null ;
194+ try {
195+ $ quoteModel = $ this ->quoteRepository ->get ($ order ->getQuoteId ());
196+ $ quote = $ quoteModel ;
197+ }catch (\Exception $ e ){
198+ $ quote = $ order ;
199+ }
200+
195201 if ($ customerId ) {
196202 $ AcCustomer = $ this ->customer ->updateCustomer ($ this ->getCustomer ($ customerId ));
197203 }else {
198204 $ customerEmail = $ quote ->getBillingAddress ()->getEmail ();
199- $ contact ['email ' ] = $ quote -> getBillingAddress ()-> getEmail () ;
205+ $ contact ['email ' ] = $ customerEmail ;
200206 $ contact ['firstName ' ] = $ quote ->getBillingAddress ()->getFirstname ();
201207 $ contact ['lastName ' ] = $ quote ->getBillingAddress ()->getLastname ();
202208 $ contact ['phone ' ] = $ quote ->getBillingAddress ()->getTelephone ();
203209 $ contact ['fieldValues ' ] = [];
204- $ AcCustomer = $ this ->customer ->createGuestCustomer ($ contact ,$ quote ->getStoreId ());
210+ $ AcCustomer = $ this ->customer ->createGuestCustomer ($ contact ,$ order ->getStoreId ());
205211 }
206212 $ customerAcId = $ AcCustomer ['ac_customer_id ' ];
207- $ this ->saveCustomerResultQuote ($ quote ,$ customerAcId );
208-
213+ if ($ quoteModel ) {
214+ $ this ->saveCustomerResultQuote ($ quote , $ customerAcId );
215+ }
209216 foreach ($ order ->getAllVisibleItems () as $ item ) {
210217 $ product = $ this ->_productRepositoryFactory ->create ()
211218 ->get ($ item ->getSku ());
@@ -227,7 +234,7 @@ public function orderDataSend($order): array
227234 "ecomOrder " => [
228235 "externalid " => $ order ->getId (),
229236 "source " => 1 ,
230- "email " => $ quote -> getBillingAddress ()-> getEmail (),
237+ "email " => $ order -> getCustomerEmail (),
231238 "orderProducts " => $ items ,
232239 "orderDiscounts " => [
233240 "discountAmount " => $ this ->activeCampaignHelper ->priceToCents ($ order ->getDiscountAmount ())
@@ -247,8 +254,10 @@ public function orderDataSend($order): array
247254 ];
248255
249256 if (!$ order ->getAcOrderSyncId ()) {
250-
251- $ AcOrderId = $ quote ->getAcOrderSyncId ();
257+ $ AcOrderId =0 ;
258+ if ($ quoteModel ){
259+ $ AcOrderId = $ quote ->getAcOrderSyncId ();
260+ }
252261 if ($ AcOrderId > 0 ){
253262 $ result = $ this ->curl ->orderDataSend (
254263 self ::UPDATE_METHOD ,
0 commit comments