How do I display a block on the checkout page based on the product type? I have created some custom blocks in code that are shown on the Drupal Commerce checkout page. I would like the block to have differ content basing on which items are in the cart. How can I achieve this in code?
Around the time some Item1 (or Item2) is added to your cart, grant that user access to a role like "HasItem1InCart" (or "HasItem2InCart"). Use the Rules module to grant such access, using a Rules Action like "Add user role".

Within the block visibility settings for Block1 (which you want to show if Item1 is in the cart), only show that block to users with roles ... you probably guessed it .... HasItem1InCart (same for Block2 and HasItem2InCart).