Showing results for 
Search instead for 
Did you mean: 

Hide product based on cookie/session value

Hide product based on cookie/session value


Is it possible to show/hide a product based on an arbitrary customer condition, e.g. a cookie value, for both logged in and out users?


For example, if a user clicks a custom 'share' button (from my module) I'd like to add a value to a cookie/session/storage, where thereafter they are able to see additional products.


I know products can be shown/hidden by a customer groups extension, however I can't add customers to a group without them being logged in. Also later there may be a need to use multiple cases of the above and a customer appears (?) to only be able to be within one customer group.


Alternatively, if hiding the products isn't possible, if there is a way of disallowing the add to cart/checkout of a product based on such a condition that would be just as good.


Re: Hide product based on cookie/session value

After saving condition in cookies, you may use an event to check and hide product / add to cart button. For hiding products, you may use this event: catalog_product_collection_load_before 




In you can get value from cookie to check on Observer:

$condition = Mage::getSingleton('core/cookie')->get('cookie_name');
If ($condition) {
   // find products to hide
   $productIds = array();
       ->addFieldToFilter('entity_id', array(
             'nin' => $productIds,

Hope this helps.