Skip to content

Instantly share code, notes, and snippets.

@cgi-caesar
Created February 18, 2020 17:01
Show Gist options
  • Save cgi-caesar/54567cdeb43fbe068d50211cb1437a1a to your computer and use it in GitHub Desktop.
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
<?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&ndash;%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