Skip to content

Instantly share code, notes, and snippets.

@cgi-caesar
Created December 25, 2020 08:47
Show Gist options
  • Save cgi-caesar/29686555c899aea15c203d5b6c7d490e to your computer and use it in GitHub Desktop.
Save cgi-caesar/29686555c899aea15c203d5b6c7d490e to your computer and use it in GitHub Desktop.
aMember (site.php): Hide sidebar for some products in shopping cart catalogue
<?php
Am_Di::getInstance()->productTable->customFields()
->add(new Am_CustomFieldSingle_Checkbox('remove_sidebar', 'Remove Sidebar?'));
Am_Di::getInstance()->front->registerPlugin(new class extends Zend_Controller_Plugin_Abstract {
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
if ($request->getModuleName() == 'cart'
&& $request->getControllerName() == 'index'
&& $request->getActionName() == 'product') {
$product = $request->getParam('path') ?
Am_Di::getInstance()->productTable->findFirstByPath($request->getParam('path')) :
Am_Di::getInstance()->productTable->load($request->getParam('id'));
if ($product->data()->get('remove_sidebar')) {
$bm = Am_Di::getInstance()->blocks;
foreach ($bm->get('cart/right') as $block) {
$bm->remove($block->getId());
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment