"post_complete_transaction" event

NikitOS

Well-known member
Since 2.1.6, there is a postCompleteTransaction method in XF\Purchasable\AbstractPurchasable. However, there may be a need to watch all completed transactions for all Purchasables, for example for sending fiscal receipts to the tax service (not from a payment provider). Extending a class for each Purchasable is inconvenient, since it is impossible to handle for every possible case, so an event like post_complete_transaction would be nice.
 
Upvote 5
Extending a class for each Purchasable is inconvenient, since it is impossible to handle for every possible case, so an event like post_complete_transaction would be nice.
Certainly inconvenient, but probably not impossible:

You could for example extend XF\Entity\Purchasable::getHandler(), check the purchasable_type_id and if it's unknown auto-generate code for the required class extension and immediately activate this via \XF::extension()->addClassExtension() before calling the parent method.

You could for example extend XF\Entity\Purchasable::getHandler() and check if the returned object implements your interface.
If it does not auto-generate code for the required class extension (probably using a trait), immediately activate this class extension via \XF::extension()->addClassExtension(), create a new object and return it.
 
Last edited:
Back
Top Bottom