Hi, I did some searching but only found results for Amember 3 so far. Ive configured an additional product and set the 'do not show for ordering button'. I would like this product to be available, and free, ONLY for people who have a different/parent product. I dont see any where to set this up yet. Of course, Id like to also expire the free add on product as soon as the parent product expires too. Thanks,
You want to set the product settings / allow & disallow settings, so that orders can only be made by members with product X/Y already active. David
Thanks, I got that part down. Now I need to figure out how to auto expire the 'add on' product when the primary product expires, since its essentially an extension to the main membership. Can I do this? Or will I need to check the subscription removed event explcititly and manually remove the add on?
How do I do that? The invoice/billing API section is blank and I cant find anything on how to expire/delete a persons product by the API. I tried the product->delete() and it deleted the whole darn product from the system! I want to delete a product by name specifically.. if(this product1 is expiring) if(they have product2) delete product2 subscription How would I do this?
Here is exact code which should work: PHP: Am_Di::getInstance()->hook->add(Am_Event::SUBSCRIPTION_DELETED, 'subscrDeleted');function subscrDeleted(Am_Event_SubscriptionDeleted $event){ $user = $event->getUser(); $product = $event->getProduct(); // If product 1 expires if($product->product_id == 1){ // Delete access for product 2 as well. foreach($user->getAccessRecords() as $a){ // if user have access to product 2 and that access is not expired yet if(($a->product_id == 2) && ($a->expire_date > Am_Di::getInstance()->sqlDate)){ $yesterday = Am_Di::getInstance()->dateTime; $yesterday->modify('-1 days'); $yesterday = $yesterday->format('Y-m-d'); $a->updateQuick('expire_date', $yesterday); } } }} Place it to /amember/application/configs/config.php