- Issue created by @khiminrm
- Status changed to Needs review
7 months ago 4:05pm 4 July 2024 - Status changed to Needs work
5 months ago 5:38pm 28 August 2024 - π©πͺGermany Anybody Porta Westfalica
@khiminrm thanks, please turn this into a MR.
- First commit to issue fork.
- Status changed to Needs review
5 months ago 10:48pm 6 September 2024 - πΊπΈUnited States rhovland Oregon
The actual problem is calling functions on
$entity
when it is null. Switching to using$order_item->getPurchasedEntityId()
and$order_item->getTitle()
handles the lack of a purchased entity gracefully and also works on non-product purchased entities, returning the name and entity id. getPurchasedEntityId() returns null instead of throwing an error if there is no purchased entity.I also moved the SKU code so it uses a null coalescing operator to determine if it should use the sku or the purchased entity id instead of overwriting values previously set.
- πΊπΈUnited States rhovland Oregon
I made a small change so it returns an empty string if the id is null
It's a stacked null coalescing operator so if
$sku
is null then it uses$order_item->getPurchasedEntityId()
and if that's also null it uses an empty string. - Merge request !25Issue #3459077 by rhovland, khiminrm: getPurchasedEntity() can return NULL β (Merged) created by rhovland
- π©πͺGermany Anybody Porta Westfalica
@rhovland looking great!
Just one last step to finish this: Is an empty string an accepted value for Facebook?
'content_name' => $order_item->getTitle()
will then still return the title, right? (Hopefully we can be sure there, it's not NULL :P) - πΊπΈUnited States rhovland Oregon
According to the order item entity interface it will always return a string. Titles are required for order items in the UI, you cannot save one without it.
/** * Gets the order item title. * * @return string * The order item title */ public function getTitle();
- Status changed to RTBC
4 months ago 6:35am 10 September 2024 - π©πͺGermany Anybody Porta Westfalica
Thanks @rhovland, so let's merge this!
-
anybody β
committed 2b243293 on 2.x authored by
rhovland β
Issue #3459077 by rhovland, khiminrm, anybody: getPurchasedEntity can...
-
anybody β
committed 2b243293 on 2.x authored by
rhovland β
- Status changed to Fixed
4 months ago 6:37am 10 September 2024 Automatically closed - issue fixed for 2 weeks with no activity.