Difference between revisions of "How to hide specific product in Active Subscriptions block"

From aMember Pro Documentation
Jump to: navigation, search
(Created page with "Add this code to site.php file, this example hide product with id 8, you can replace 8 with desired value: <source> Am_Di::getInstance()->hook->add(Am_Event::BEFORE_RENDER...")
 
 
Line 1: Line 1:
Add this code to [[site.php file]], this example hide product with id 8, you can replace 8 with desired value:
+
Add this code to [[site.php file]]. This example hide product with id 8, you can replace 8 with desired value:
 
<source>
 
<source>
 
Am_Di::getInstance()->hook->add(Am_Event::BEFORE_RENDER, function(Am_Event $e) {
 
Am_Di::getInstance()->hook->add(Am_Event::BEFORE_RENDER, function(Am_Event $e) {

Latest revision as of 05:08, 11 November 2016

Add this code to site.php file. This example hide product with id 8, you can replace 8 with desired value:

Am_Di::getInstance()->hook->add(Am_Event::BEFORE_RENDER, function(Am_Event $e) {
    if (strpos($e->getTemplateName(), 'member-main-subscriptions.phtml')!==false) {
        $v = $e->getView();
        foreach ($v->member_products as $k => $p) {
            if ($p->pk() == 8) {
                unset($v->member_products[$k]);
                return;
            }
        }
    }
});