custom confirmation email for orders using global cart

Hi,

I am developing a site, which acts as a marketplace with multiple sellers, using the global cart. I have disabled the default store emails that get sent to customers, whenever a purchase is made. Instead I am developing a solution where the customer receives only ONE confirmation email from the site.

I almost have this working correctly, except for 1 glitch. When I make an order that has items coming from different stores, the email will tell me the items that I have ordered but repeat them X amount of times (where X = the number of stores bought from). In the code below this is the line:
$msgC_items .= '<li>'.$qty.' '.$item_title.' (£'.$price.') - Sold by: '.$blogName.'</li>';

e.g. if i buy 2 items (1 from each store), my email will say that i've bought these items:
- item1
- item2
-item1(repeated)
-item2(repeated)

Can anyone spot the mistake in the code? (to simplify reading it, i've used ... to describe the default code in the php file)

paypal-express.php

function process_payment($global_cart, $shipping_info) {
  global $mp, $blog_id, $site_id, $switched_stack, $switched;

	  $blog_id = (is_multisite()) ? $blog_id : 1;
	  $current_blog_id = $blog_id;

	  if (!$mp->global_cart)
	  	$selected_cart[$blog_id] = $global_cart;
	  else
	    $selected_cart = $global_cart;

  if (isset($_SESSION['token']) && isset($_SESSION['PayerID']) && isset($_SESSION['final_amt'])) {
    //attempt the final payment
    $result = $this->DoExpressCheckoutPayment($_SESSION['token'], $_SESSION['PayerID']);

    //check response
    if($result["ACK"] == "Success" || $result["ACK"] == "SuccessWithWarning")	{

      .......

			//succesful payment, create our order now
	        $mp->create_order($_SESSION['mp_order'], $selected_cart[$bid], $shipping_info, $payment_info, $paid);	

			//MY CODE STARTS FROM HERE
			// EMAIL THE CUSTOMER THE TOTAL ORDER.
				global $wpdb;

						$orderConfirmation = "Order Confirmation (".$order_id.")";
						$orderId = $order_id;
						$sql = "SELECT * FROM 'wp_".$bid."_posts</code> where post_title = '".$orderId."'";
									$getProducts1 = $wpdb->get_row($sql,ARRAY_A);
									$productDetails1 = $getProducts1;
									$order_date = $productDetails1['post_date'];
						$msgC = '<!DOCTYPE html><html><head></head><body>';
						$msgC .= "<b> Thank you for shopping on our site! Your order (".$order_id.") has been placed.</b>";
						$msgC .= "<p>Order Placed: ".$order_date."</p>";
						$msgC .= "<p>Order ID: ".$order_id."</p>";

							foreach ($global_cart as $bid => $cart)
								{
									$blogName = get_blog_option($bid,'blogname');

										foreach ($cart as $product_id => $data) {

										/* For each product in a store's cart */
										$price = $data[0]['price'];
										$qty = $data[0]['quantity'];
										$item_title = $data[0]['name'];
										$msgC_items .= '<li>'.$qty.' '.$item_title.' (£'.$price.') - Sold by: '.$blogName.'</li>';	

										$orderPostId = $getProducts['ID'];
										$ismail = get_post_meta($orderPostId,'is_mail',true);
										if(empty($ismail)){
											add_post_meta($orderPostId,'is_mail',true);
										}
										$customerName = $shipping_info['name'];
										$customerBillingAddress =  $shipping_info['address1'].', '.$shipping_info['address2'];
										$customerBillingPhone =  $shipping_info['phone'];
										}

								} //end foreach $global_cart

				} //end if($result["ACK"] 

				$msg_customer = '<p>Customer Information:</p><ul style="list-style-type: none;"><li>Name: '.$customerName.'</li><li>Address: '.$customerBillingAddress.'</li><li>Phone: '.$customerBillingPhone.'</li></ul>';
				$msgC .= $msg_customer.'<p>Order Information:</p><p>Items:</p><ul>'.$msgC_items.'</ul></body></html>';
				$toC = $shipping_info['email'];
				$blogNameNetwork =  get_blog_option(1,'blogname');
				$subject = $orderConfirmation;
				$messageC = $msgC;
				$headers = 'Content-type: text/html';
				wp_mail( $toC, $subject, $messageC, $headers);

				        if (is_multisite())
				    			switch_to_blog($current_blog_id, true);

			} //end if (isset($_SESSION
			else{.....}

}		//end of function process_payment