Countdown to expiry date

Discussion in 'Troubleshooting' started by crazyfrog, Jul 15, 2006.

  1. crazyfrog

    crazyfrog New Member

    Joined:
    Jul 15, 2006
    Messages:
    8
    I am working on a trial version of the script at the moment for an insight into what amember can do before setting up for a client.
    The question is this:

    How would i go about setting up some sort of countdown to expiration date.

    Something like - Your subscription ends in ** Days.

    Would love to see this also available as a mod to show on a non amember page as has been done with the login form.

    Thankyou for looking :)
  2. redlinecd

    redlinecd New Member

    Joined:
    Feb 14, 2004
    Messages:
    1
    I also requested this feature a long time ago but did not see it implemented yet.
  3. cemper

    cemper Member

    Joined:
    Sep 27, 2006
    Messages:
    41
    hmmm... that#s not there? that should be just 1 line of php code
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Sure! If member has just one active subscription.
    What if there are several subscriptions?
  5. crazyfrog

    crazyfrog New Member

    Joined:
    Jul 15, 2006
    Messages:
    8
    My members cannot have multiple subscriptions, so how could it be done for single subscription.
    Any ideas are welcomed.:)
  6. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    PHP:
    <?php
    session_start
    ();
    foreach (
    $_SESSION['_amember_subscriptions'] as $sub) ;
    if (
    $sub['payment_id']){
      
    $diff = (strtotime($s['expire_date']) - time()) / (3600*24);
      if (
    $diff 0){
         print 
    "Your subscription expires in $diff days";
      }
    }
    ?>
  7. crazyfrog

    crazyfrog New Member

    Joined:
    Jul 15, 2006
    Messages:
    8
    :(
    Code:
    Warning: Invalid argument supplied for foreach()
    I am trying to display on a none amember page. Would this be the problem?

    Thanks though:)
  8. crazyfrog

    crazyfrog New Member

    Joined:
    Jul 15, 2006
    Messages:
    8
    This is not an array possibly, how can i rectify it please?:eek:
  9. crazyfrog

    crazyfrog New Member

    Joined:
    Jul 15, 2006
    Messages:
    8
    Thanks,

    I am fairly new to php and finding it very interesting.
    I asked the following question elsewhere and this was the result.
    I ran this code, and the outcome was false. :confused:
    Code:
    var_dump(is_array($_SESSION['_amember_subscriptions']));
    if you have bool (true), it is an array, false mean it is not.

    Any help is greatly appreciated. I have lost my hair trying to get this to run!:p
  10. jenolan

    jenolan aMember Coder

    Joined:
    Nov 3, 2006
    Messages:
    510
    This will list all current subscriptions for a user, the database stuff is you prefix (ie amember_ or your DB abd prefix ie my_db.amember_) you must have already created a mysql connection.

    Code:
    function Get_aMember_Subscriptions( $member, $Database_Details )
    {
    	$sql = "SELECT member_id FROM {$Database_Details}members WHERE login='{$member}'";
    	$result = mysql_query( $sql );
    	if( $result === false )
    	{
    		die( "mySQL Error Query failed" );
    	}
    	$user = mysql_fetch_array( $result );   
    	if( $result === false )
    	{
    		die( "mySQL Error :: No user" );
    	}
    	$sql = "SELECT * FROM {$Database_Details}payments
    			WHERE member_id = {$user[ 'member_id' ]}
    				AND begin_date <= NOW() 
    				AND expire_date >= NOW()
    				AND completed > 0
    				ORDER BY product_id
    			";
    	$result = mysql_query( $sql );
    	if( $result === false )
    	{
    		die( "mySQL Error Query failed" );
    	}
    	$prods = array();
    	if( mysql_num_rows( $result ) == 0 )
    	{
    		return( prods );
    	}
    	while( 	$prod = mysql_fetch_array( $result ) )
    	{
    		$prods[] = $prod;
    	}
    	return( $prods );
    }
    
    You can then select the product you want and display information for that one as you wish.

    If you want a specific version for your site ready to roll I will do it for US$25.

    Larry

Share This Page