Found answer to my own question. I discovered the conditional rules module and came up with this rule component for each product type:
{ "rules_empty_cart__consumer_g" : {
"LABEL" : "Empty cart - consumer g",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "rules_conditional", "commerce_cart", "commerce_order" ],
"ON" : { "commerce_cart_product_prepare" : [] },
"IF" : [
{ "data_is" : { "data" : [ "commerce-product:type" ], "value" : "store_item" } }
],
"DO" : [
{ "CONDITIONAL" : [
{
"IF" : { "commerce_order_contains_product_type" : {
"commerce_order" : [ "commerce_order" ],
"product_type" : { "value" : {
"product" : "product",
"book" : "book",
"food" : "food"
}
},
"operator" : "\u003E=",
"value" : "1"
}
},
"DO" : [
{ "commerce_cart_empty" : { "commerce_order" : [ "commerce_order" ] } },
{ "drupal_message" : { "message" : "cart cleared!" } }
]
}
]
}
]
}
}
What this does is it every time an item is to be added to cart it checks if there at least one item in the cart that is not of the same product-type as the product that is about to be added. If there is, the cart is cleared before the item is added, if not the cart remains unchanged and the new item added to the existing list on the cart.
For this check to happen irrespective of the type, a similar rule is created per product type.