$cart = hikashop::get('class.cart');
$products = $cart->get();
if(!empty($products)){
$ids = array();
foreach($products as $k => $row){
$ids[]=$row->product_id;
}
$db =& JFactory::getDBO();
$db->setQuery('SELECT category_id FROM '.hikashop::table('product_category').' WHERE product_id ='.$this->element->category_id);
$current_category_id = $db->loadResult();
$db->setQuery('SELECT category_id FROM '.hikashop::table('product_category').' WHERE product_id IN ('.implode(',',$ids).')');
$category_id = $db->loadResult();
if($category_id==$current_category_id){
//display add to cart
}
}