I manage to narrow it down as follows
$cartClass = hikashop_get('class.cart');
$productsArray = $cartClass->get();
$cart_id = $cartClass->cart_id;
$db = JFactory::getDBO();
$query = 'SELECT sum(cart_product_quantity)cnt FROM '.hikashop_table('cart_product').' where cart_id = \'$cart_id\' and cart_product_option_parent_id = \'0\' and cart_product_quantity > \'0\' ';
$db->setQuery($query );
$db_obj = $db->loadObjectList();
// To test i get the values immediately , i directly assign the value to the shipping price
$rate->shipping_price = $db_obj->cnt;
But i keep getting 0 for the $db_obj->cnt , the supposedly value should be three.. I tested this query in phpmyadmin and it worked.