Created
October 30, 2017 12:24
-
-
Save cgi-caesar/898c8f9da251c387ae4134ad7d20874e to your computer and use it in GitHub Desktop.
Exclude certain products from shopping cart directory
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()->productTable->customFields()->add(new Am_CustomFieldCheckbox('cart_exclude', 'Exclude from Shopping Cart')); | |
Am_Di::getInstance()->hook->add('cartGetProductsQuery', function(Am_Event $e) { | |
/* @var $q Am_Query */ | |
$q = $e->getQuery(); | |
$q->leftJoin('?_data', 'd', "d.`table` = 'product' AND d.`key` = 'cart_exclude' AND d.`id` = p.product_id"); | |
$q->addWhere('d.`value` IS NULL OR d.`value`<>1'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment