Created
March 27, 2020 09:54
-
-
Save cgi-caesar/ed6c1df4b31889a49a8a3bfed3b8308b to your computer and use it in GitHub Desktop.
aMember (site.php): Show qty within Active Subscriptions 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, 'item-qty', null, function(Am_View $v) { | |
| $di = Am_Di::getInstance(); | |
| $user = $di->user; | |
| $_ = $user->getActiveProductIds(); | |
| $out = []; | |
| foreach ($_ as $pid) { | |
| $qty = $di->db->selectCell(<<<CUT | |
| SELECT SUM(qty) | |
| FROM ?_access | |
| WHERE user_id = ? | |
| AND product_id = ? | |
| AND begin_date<=? | |
| AND expire_date>=? | |
| CUT | |
| , | |
| $user->pk(), | |
| $pid, | |
| sqlDate('now'), | |
| sqlDate('now') | |
| ); | |
| if ($qty > 1) { | |
| $out[] = " jQuery('#member-subscriptions #product-item-{$pid} .am-list-subscriptions-title strong').after(' ({$qty})');"; | |
| } | |
| } | |
| 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