nystudio107 / craft-instantanalytics-ga4

Instant Analytics brings full Google GA4 server-side analytics support to your Twig templates and automatic Craft Commerce integration
Other
3 stars 4 forks source link

Fix: purchasable nullpointer #28

Closed Numkil closed 7 months ago

Numkil commented 8 months ago

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

khalwat commented 7 months ago

Many thanks, I'll backport it to the Craft 3 version as well!

khalwat commented 7 months ago

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

Numkil commented 7 months ago

Thank you :)