From 55196e17949d203bcb30c772e677aaf6c7be99d4 Mon Sep 17 00:00:00 2001 From: Jigar Sangoi Date: Thu, 19 Dec 2024 19:25:29 +0530 Subject: [PATCH 1/2] Null customer email when you have Guest checkout enabled --- .../Services/MarketingAutomationManager.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Plugins/Nop.Plugin.Misc.Brevo/Services/MarketingAutomationManager.cs b/src/Plugins/Nop.Plugin.Misc.Brevo/Services/MarketingAutomationManager.cs index f518583eeb3..47cb98969d2 100644 --- a/src/Plugins/Nop.Plugin.Misc.Brevo/Services/MarketingAutomationManager.cs +++ b/src/Plugins/Nop.Plugin.Misc.Brevo/Services/MarketingAutomationManager.cs @@ -252,11 +252,13 @@ public async Task HandleOrderCompletedEventAsync(Order order) ArgumentNullException.ThrowIfNull(order); var customer = await _customerService.GetCustomerByIdAsync(order.CustomerId); + var shippingAddress = await _addressService.GetAddressByIdAsync(order.ShippingAddressId ?? 0); + var billingAddress = await _addressService.GetAddressByIdAsync(order.BillingAddressId); try { //first, try to identify current customer - await _marketingAutomationHttpClient.RequestAsync(new IdentifyRequest { Email = customer.Email }); + await _marketingAutomationHttpClient.RequestAsync(new IdentifyRequest { Email = customer.Email ?? billingAddress.Email }); //get URL helper var urlHelper = _urlHelperFactory.GetUrlHelper(_actionContextAccessor.ActionContext); @@ -296,9 +298,6 @@ public async Task HandleOrderCompletedEventAsync(Order order) }; }).ToArrayAsync(); - var shippingAddress = await _addressService.GetAddressByIdAsync(order.ShippingAddressId ?? 0); - var billingAddress = await _addressService.GetAddressByIdAsync(order.BillingAddressId); - var shippingAddressData = new { firstname = shippingAddress?.FirstName, From d215943ad8221c24a4802ba4eeed8e4c40e9cc58 Mon Sep 17 00:00:00 2001 From: Jigar Sangoi Date: Fri, 20 Dec 2024 18:24:36 +0530 Subject: [PATCH 2/2] 1 more place raising error --- .../Services/MarketingAutomationManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugins/Nop.Plugin.Misc.Brevo/Services/MarketingAutomationManager.cs b/src/Plugins/Nop.Plugin.Misc.Brevo/Services/MarketingAutomationManager.cs index 47cb98969d2..28544138eb3 100644 --- a/src/Plugins/Nop.Plugin.Misc.Brevo/Services/MarketingAutomationManager.cs +++ b/src/Plugins/Nop.Plugin.Misc.Brevo/Services/MarketingAutomationManager.cs @@ -355,7 +355,7 @@ public async Task HandleOrderCompletedEventAsync(Order order) //create track event object var trackEvent = new TrackEventRequest { - Email = customer.Email, + Email = customer.Email ?? billingAddress.Email, EventName = BrevoDefaults.OrderCompletedEventName, EventData = new { id = $"cart:{shoppingCartGuid}", data = cartData } };