Rules to clear commerce cart on adding new item of a different product type I've several product type with corresponding product displays. The scenario is a case where there is only a product type per time on the cart. That is, you cannot  have multiple product types at the same on the cart. Hence, each time a new item is to be added, check if it is of the same type as the existing items in the cart. If it is add, if not clear cart before adding the new item.

What rule setting can help me in achieving this. Thank you.
Found answer to my own question. I discovered the conditional rules module and came up with this rule component for each product type:
{ &quot;rules_empty_cart__consumer_g&quot; : {
    &quot;LABEL&quot; : &quot;Empty cart - consumer g&quot;,
    &quot;PLUGIN&quot; : &quot;reaction rule&quot;,
    &quot;OWNER&quot; : &quot;rules&quot;,
    &quot;REQUIRES&quot; : [ &quot;rules&quot;, &quot;rules_conditional&quot;, &quot;commerce_cart&quot;, &quot;commerce_order&quot; ],
    &quot;ON&quot; : { &quot;commerce_cart_product_prepare&quot; : [] },
    &quot;IF&quot; : [
      { &quot;data_is&quot; : { &quot;data&quot; : [ &quot;commerce-product:type&quot; ], &quot;value&quot; : &quot;store_item&quot; } }
    ],
    &quot;DO&quot; : [
      { &quot;CONDITIONAL&quot; : [
          {
            &quot;IF&quot; : { &quot;commerce_order_contains_product_type&quot; : {
                &quot;commerce_order&quot; : [ &quot;commerce_order&quot; ],
                &quot;product_type&quot; : { &quot;value&quot; : {
                    &quot;product&quot; : &quot;product&quot;,
                    &quot;book&quot; : &quot;book&quot;,
                    &quot;food&quot; : &quot;food&quot;
                  }
                },
                &quot;operator&quot; : &quot;\u003E=&quot;,
                &quot;value&quot; : &quot;1&quot;
              }
            },
            &quot;DO&quot; : [
              { &quot;commerce_cart_empty&quot; : { &quot;commerce_order&quot; : [ &quot;commerce_order&quot; ] } },
              { &quot;drupal_message&quot; : { &quot;message&quot; : &quot;cart cleared!&quot; } }
            ]
          }
        ]
      }
    ]
  }
}

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.