Created
February 18, 2020 17:01
-
-
Save cgi-caesar/54567cdeb43fbe068d50211cb1437a1a to your computer and use it in GitHub Desktop.
aMember (site.php): Show expiration date for future access periods in Active Subscription Widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Am_Di::getInstance()->blocks->add('member/main/bottom', new Am_Block_Base(null, 'future-dates', null, function(Am_View $v) { | |
$user = Am_Di::getInstance()->user; | |
$_ = $user->getFutureProductsBeginning(); | |
$out = []; | |
foreach ($_ as $pid => $begin) { | |
$period = json_encode($user->getExpire($pid) == Am_Period::MAX_SQL_DATE ? | |
sprintf("begins %s", amDate($begin)) : | |
sprintf("%s–%s", amDate($begin), amDate($user->getExpire($pid)))); | |
$out[] = " jQuery('#member-subscriptions #product-item-{$pid} .am-list-subscriptions-date').html({$period});"; | |
} | |
if ($out) { | |
$out = implode("\n", $out); | |
return <<<CUT | |
<script> | |
jQuery(function(){ | |
{$out} | |
}); | |
</script> | |
CUT; | |
} | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment