I'm iterating through the subscription session variable like this: Code: foreach ($_SESSION['_amember_subscriptions'] as $s) Within that, I can emit the expiration date for the product/subscription: Code: echo $s[expire_date]; Problem with this is the subscription may have been renewed, but the subscription session expiration for this product is the ORIGINAL expiration, not the renewed expiration. How do I get the renewed expiration date? I don't see the renewal product in the subscription session.
Renewal will not be included in $_SESSION['_amember_subscriptions'] array if it have future status so is not active yet. This array contain only active subscriptions.
You can query database. For example: Code: select max(expire_date) from amember_payments where member_id = MEMBER_ID and product_id = PRODUCT_ID and completed =1
Thanks again Alexander. I am still using amember in a test environment, and not yet on a real site. Am I correct in that a subscription's renewal is its own unique product_id, and not the same product_id as the original? If so, retrieving the maximum expire date for the current product isn't going to be any different than using the expiration date in the cookie.... or am I missing something?
This depends on how you set your products. If you use recurring products, next payment will be created with the same product_id. if you create separate product for renewals you can check all products within the same group: Code: select max(expire_date) from amember_payments where member_id = MEMBER_ID and product_id in (PRODUCT_ID1, PRODUCT_ID2,PRODUCT_ID3) and completed =1
Payments will not be recurring - member choose whether or not to renew. The code example you provide presumes the code I am planning to use will know all the related product IDs... This is not the case. The related product ids could be several and subject to change, so I need something more dynamic. Is this not the purpose of the renewal group id? What would be the syntax of retrieving the max expire date across the renewal group id? Also, allow me to make a request. In addition to a renewal group ID, it would be very beneficial to have a renewal group name and to make both the renewal group ID and renewal group name available via the subscription cookie. Any chance that can be incorporated into an upcoming version of aMember?
You can get product_ids depending on renewal group without a problem: Code: foreach($db->get_products_list() as $p){ if($p[renewal_group] == "GOLD"){ $gold_products[$p[product_id]] = $p; } }
I'm pulling my hair out here, and its probably something simple that I am missing. Perhaps I am not being clear. Let me reiterate and simplify what I want to show for a logged in user. These are the products possible/renewal group Silver original/Silver Silver renewal option a/Silver Silver renewal option b/Silver Silver renewal option c/Silver Gold original/Gold Gold renewal option a/Gold Gold renewal option b/Gold Gold renewal option c/Gold Each of the above, while different products, share a common renewal group name of either Silver or Gold. Let us assume that a user has the following active subscriptions: Silver original Gold original User has also subscribed to Silver renewal option a, Silver renewal option b, Gold renewal option a, and Gold renewal option b Silver & Gold renewal option a will begin when original expires (assume Feb 1, 2010). Likewise, Silver/Gold renewal option b will begin when renewal option a expires (assume Mar 1, 2010). A logged in user only has only the original subscriptions which I can display with something like: Code: foreach ($_SESSION['_amember_products'] as $p) { echo $p['title']; } However, I do not want the current product title because when the original expires, and the renewal begins, I do NOT want a product listed as "Silver renewal option a - I still want it to display the renewal group, so I do it this way instead: Code: foreach ($_SESSION['_amember_products'] as $p) { echo $p['renewal_group']; } I want a simple info box in my php page. All I want in that box is "Renewal Group Name - maximum expire date", ie: Silver - March 31, 2010 Gold - March 31, 2010 I'm guessing its going to look something like this, but I don't seem to have this quite right just yet.. I also need this to work in my own php page, which is outside of aMember... I thought this was as simple as include "path/to/config.inc.php" but that seems to be triggering an error "WARNING: Cannot modify header information - headers already sent". Code: foreach ($_SESSION['_amember_products'] as $p) { //Use $p['renewal_group'] to get all products that share this renewal group foreach($db->get_products_list() as $z){ if($z[renewal_group] == $p[renewal_group]){ $same_renewal_products[$z[product_id]] = $z; } } //Return latest expiration date from payments for any products that share this renewal group $max_group_expire=$db->query("SELECT max(expire_date) from amember_payments WHERE member_id = $aMember_user['member_id']' and product_id in $same_renewal_products and completed ='1')"; echo $p[renewal_group], ' - ', $max_group_expire; } So, my code above seems close to correct, but obviously does not work. I still don't know what exactly to add to my foreign php page so that it can do a db lookup in aMember.... HELP!!! I'M GOING CRAZY!!
Well if there is exact code that you use, it will not work because of several errors in syntax and logic. Please contact me in helpdesk and attach exact file with your modifications I will provide exact example.
If you have a quick suggestion, I would appreciate your posting here so that the answer would benefit anyone else seeking similar functionality. I cannot even begin to test the above theory, because I cannot seem to include the aMember framework in my script. I don't think its related to aMember though... will try resolve that issue first, but if you have a code suggestion for what I am trying to accomplish, I'd love to give it a try.