Hello all, Quick question.. I'm working on a module that will update another database that we control (it stores items from the invoice) whenever access record is created. As of now, I have it working using onPaymentWithAccessAfterInsert and I access the invoice items using $event->getInvoice(); But... this doesn't seem to work for free subscriptions... For a free subscription, would I use onAccessAfterInsert instead? If so - how do I access the invoice items from within this function? I tried doing it the same way as onPaymentWithAccessAfterInsert, but it didn't seem to work. Any help is greatly appreciated! Thanks!
Hello, First of all access not always associated with invoice. Admin can add access records from admin interface without invoices. Also there is may be other cases when access record has not associated invoice record. I believe it is important to keep in mind. Second here is code to access invoice from onAccessAfterInsert: PHP: function onAccessAfterInsert(Am_Event $e){ /** @var Access $access */ $access = $e->getAccess(); if ($access->invoice_id) { $invoice = $e->getDi()->invoiceTable->load($access->invoice_id); }} Third this event Am_Event::ACCESS_AFTER_INSERT cover both cases free and paid subscriptions. So you need to remove handler onPaymentWithAccessAfterInsert, otherwise you will have two records in your database for same single access record in aMember. Best Regards.
hmmm, so it looks like that part worked for me, thanks again! BUT... i must not be using the correct method to get the user data also... in my onPaymentwithAccessAfterInsert, I was able to use $event->getUser(); Will that method not work for onAccessAfterInsert as well?