The core of the e-commerce part of the overall solution. This is an ecommerce shopping cart solution built on top of the DNN (DotNetNuke) CMS. Anyone can do commerce online now!
The bug was occurring due to a null reference error when attempting to access the HccRequestContext object. The previous code did not properly initialize the _current object, leading to the null reference.
To resolve this issue, I added a check to ensure that the HttpContext.Current is not null. If it is null, I initialize the _current object as a new HccRequestContext instance. This ensures that the object is properly initialized and prevents the null reference error from occurring.
How Has This Been Tested?
I have thoroughly tested the changes in various scenarios, and the bug no longer occurs. The application now correctly handles the HccRequestContext object, ensuring smooth execution without null reference errors.
All emails for abandoned carts are being sent successfully.
Screenshots (if appropriate):
Img1. Emails sent successfully.
Img2. No exception in the Admin logs
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
Checklist:
[x] My code follows the code style of this project.
[ ] My change requires a change to the documentation.
Related to Issue
Fixes # https://github.com/HotcakesCommerce/hotcakes-commerce-core/issues/454 Abandoned Cart Email throwing exception
Description
The bug was occurring due to a null reference error when attempting to access the HccRequestContext object. The previous code did not properly initialize the _current object, leading to the null reference.
To resolve this issue, I added a check to ensure that the HttpContext.Current is not null. If it is null, I initialize the _current object as a new HccRequestContext instance. This ensures that the object is properly initialized and prevents the null reference error from occurring.
How Has This Been Tested?
I have thoroughly tested the changes in various scenarios, and the bug no longer occurs. The application now correctly handles the HccRequestContext object, ensuring smooth execution without null reference errors.
All emails for abandoned carts are being sent successfully.
Screenshots (if appropriate):
Img1. Emails sent successfully.
Img2. No exception in the Admin logs
Types of changes
Checklist: