Custom block doesn't work correctly when not logged in
You block is build on the first page request. The else flow is followed. Depending on you settings the page or block is cached. Logged in users don't have cached blocks.

That it worked now and then for anonymous was probably due to your cache clears.

You should create a callback using hook_menu() like

function innovista_donate_menu() {
  return array(
    'innovista/addtocart' =&gt; array(
      'title' =&gt; 'Innovisata add to cart',
      'page callback' =&gt; 'innovista_donate_add_to_cart',
      'access callback' =&gt; TRUE, // Accessible for everybody
      'type' =&gt; MENU_CALLBACK,
    ),
  );
}

function innovista_donate_add_to_cart() {
  if(isset($_GET['d'])){
    switch ($_GET['d']) {
      case 1:
        $product_id='6';
        break;
      case 2:
        $product_id='8';
        break;
    }       
    commerce_cart_product_add_by_id($product_id, 1, TRUE);
    drupal_goto('checkout');
  }
}


Your block can now contain just the links. You can now disabled PHP input filter probably too.

(Note I changed your drupal_goto and removed tabs)