Variable for date (year) of Expiration

Discussion in 'Customization & add-ons' started by unmortal, Jan 20, 2015.

  1. unmortal

    unmortal New Member

    Joined:
    Sep 10, 2006
    Messages:
    25
    I'm looking to get the year of the subscription expiration in a variable, and append that into a custom SQL field.
    I could maybe fumble through with site.php code to append ", 2015" or ", 15" to a database field (after payment) but how do I get the year of expiration?
  2. unmortal

    unmortal New Member

    Joined:
    Sep 10, 2006
    Messages:
    25
    I was able to get the expiration date and subtract the month and day, leaving just the year. Now I'm wondering if someone can tell me if this code might work within site.php? Can I use concat like I'm doing below?

    Code:
    Am_Di::getInstance()->hook->add('paymentAfterInsert', 'customPaymentAfterInsert');
    function customPaymentAfterInsert(Am_Event_PaymentAfterInsert $event)
    {
            $ExpDate=Am_Lite::getInstance()->getExpire();
            $ExpYear=substr($ExpDate, 0, 4);
            $ExpYearForm=", $ExpYear";
            $payment = $event->getPayment();
            $user = $invoice->getUser();
            $user->history = concat(history, '$ExpYearForm');
            $user->update();
    }

Share This Page