Null Error when an Order Item without an purchasable entity is completed

Created on 28 September 2023, 9 months ago
Updated 28 January 2024, 5 months ago

Problem/Motivation

When an Order Item without an purchasable entity is completed in an order (in our case a "Donation" item) Simple Facebook Pixel throws the following error:
Error: Call to a member function getSku() on null in Drupal\simple_facebook_pixel\EventSubscriber\PixelSubscriber->purchaseEvent() (line 215 of modules/contrib/simple_facebook_pixel/src/EventSubscriber/PixelSubscriber.php).

Steps to reproduce

Create an Order Item that has no purchasable entity. Set Simple Facebook Pixel to track Purchase in the admin (/admin/config/system/simple-facebook-pixel). Complete checkout and you will see the error

Proposed resolution

Check for Null case on Order Item Purchased Entity

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom code-brighton

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024