Closed Numkil closed 7 months ago
Many thanks, I'll backport it to the Craft 3 version as well!
Addressed in:
Craft CMS 3.x: Version 3.0.1 -> https://github.com/nystudio107/craft-instantanalytics-ga4/releases/tag/3.0.1
Craft CMS 4.x: Version 4.0.1 -> https://github.com/nystudio107/craft-instantanalytics-ga4/releases/tag/4.0.1
Thank you :)
Description
Hi I ran into this problem with a client of mine who kept locking themselves out of the frontend of their website as they were removing product variants they were no longer stocking on their website. It seems that the Purchasable Object can be null on a LineItem if the product variant has been deleted in the backend while still being in basket of a user. This will throw an error if the code is trying to execute getSku() on a null object.
When rendering the cart on the frontend Craft Commerce will automatically remove them from the basket and trigger a RemoveFromCart event which will then call this method into which I added the nullpointer check.
Related issues