class PluginNamePlugin extends BasePlugin
{
   public function init()
   {
      // Clear cart before new product is added
      craft()->on('commerce_cart.onBeforeAddToCart', function($event){
         $cart = craft()->commerce_cart->getCart();
         craft()->commerce_cart->clearCart($cart);
      });
   }

   ...

}