/**
  * Add Menu Cart to menu
  * 
  * @return menu items including cart
  */
 public function submenu_items()
 {
     global $wpsc_cart, $options;
     $get_cart = wpsc_cart_item_count();
     $submenu_items = '';
     //see jigoshop/widgets/cart.php
     if (count($get_cart) > 0) {
         //foreach ( $get_cart as $cart_item_key => $values ) {
         while (wpsc_have_cart_items()) {
             wpsc_the_cart_item();
             //$_product = $values['data'];
             if (wpsc_cart_item_count() > 0) {
                 global $wpsc_cart, $options;
                 $item_thumbnail = '<img src=' . wpsc_cart_item_image() . '>';
                 $item_name = wpsc_cart_item_name();
                 $item_quantity = wpsc_cart_item_quantity();
                 $item_price = wpsc_cart_item_price();
                 // Item permalink
                 $item_permalink = wpsc_cart_item_url();
                 $submenu_items[] = array('item_thumbnail' => $item_thumbnail, 'item_name' => $item_name, 'item_quantity' => $item_quantity, 'item_price' => $item_price, 'item_permalink' => $item_permalink);
             }
             //}
         }
     } else {
         $submenu_items = '';
     }
     return $submenu_items;
 }
			<td class="firstcol"><img src='<?php 
        echo wpsc_cart_item_image(48, 48);
        ?>
' alt='<?php 
        echo wpsc_cart_item_name();
        ?>
' title='<?php 
        echo wpsc_cart_item_name();
        ?>
' /></td>
			<td class="firstcol">
			<a href='<?php 
        echo wpsc_cart_item_url();
        ?>
'><?php 
        echo wpsc_cart_item_name();
        ?>
</a>
			</td>
			<td>
				<form action="<?php 
        echo get_option('shopping_cart_url');
        ?>
" method="post" class="adjustform">
					<input type="text" name="quantity" size="2" value="<?php 
        echo wpsc_cart_item_quantity();
        ?>
"/>
					<input type="hidden" name="key" value="<?php 
        echo wpsc_the_cart_item_key();
        ?>
		<td><?php echo __('Product', 'wpsc'); ?>:</td>
		<td><?php echo __('Quantity', 'wpsc'); ?>:</td>
		<?php if(wpsc_uses_shipping()): ?>
			<td><?php echo __('Shipping', 'wpsc'); ?>:</td>
		<?php endif; ?>
		<td><?php echo __('Price', 'wpsc'); ?>:</td>
		<td></td>
	</tr>
	<?php while (wpsc_have_cart_items()) : wpsc_the_cart_item(); ?>
	
	<?php  //this displays the confirm your order html	?>
		
		<tr class="product_row">
			<td class="firstcol"><img src='<?php echo wpsc_cart_item_image(48,48); ?>' alt='<?php echo wpsc_cart_item_name(); ?>' title='<?php echo wpsc_cart_item_name(); ?>' /></td>
			<td class="firstcol">
			<a href='<?php echo wpsc_cart_item_url();?>'><?php echo wpsc_cart_item_name(); ?></a>
			</td>
			<td>
				<form action="<?php echo get_option('shopping_cart_url'); ?>" method="post" class="adjustform">
					<input type="text" name="quantity" size="2" value="<?php echo wpsc_cart_item_quantity(); ?>"/>
					<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
					<input type="hidden" name="wpsc_update_quantity" value="true"/>
					<input type="submit" value="<?php echo __('Update', 'wpsc'); ?>" name="submit"/>
				</form>
			</td>
			<?php if(wpsc_uses_shipping()): ?>
			<td><span class="pricedisplay" id='shipping_<?php echo wpsc_the_cart_item_key(); ?>'><?php echo wpsc_cart_item_shipping(); ?></span></td>
			<?php endif; ?>
			<td><span class="pricedisplay"><?php echo wpsc_cart_item_price(); ?></span></td>
			<td>
			
function Usecase($seperator, $sessionid, $fromcheckout)
{
    global $wpdb, $wpsc_cart;
    $purchase_log_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1";
    $purchase_log = $wpdb->get_results($purchase_log_sql, ARRAY_A);
    $cart_sql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`='" . $purchase_log[0]['id'] . "'";
    $wp_cart = $wpdb->get_results($cart_sql, ARRAY_A);
    $merchant_id = get_option('google_id');
    $merchant_key = get_option('google_key');
    $server_type = get_option('google_server_type');
    $currency = get_option('google_cur');
    $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);
    $transact_url = get_option('transact_url');
    $returnURL = $transact_url . $seperator . "sessionid=" . $sessionid . "&gateway=google";
    $cart->SetContinueShoppingUrl($returnURL);
    $cart->SetEditCartUrl(get_option('shopping_cart_url'));
    $no = 1;
    //exit("<pre>".print_r($wpsc_cart,true)."</pre>");
    //new item code
    $no = 0;
    //	$cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);
    //	foreach($wpsc_cart->cart_items as $item){
    //google prohibited items not implemented
    $curr = new CURRENCYCONVERTER();
    $currency_code = $wpdb->get_results("SELECT `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . get_option('currency_type') . "' LIMIT 1", ARRAY_A);
    $local_currency_code = $currency_code[0]['code'];
    //	    exit('<pre>'.print_r($_REQUEST,true).'</pre>');
    $google_curr = get_option('google_cur');
    while (wpsc_have_cart_items()) {
        wpsc_the_cart_item();
        if ($google_curr != $local_currency_code) {
            $google_currency_productprice = $curr->convert(wpsc_cart_item_price(false) / wpsc_cart_item_quantity(), $google_curr, $local_currency_code);
            $google_currency_shipping = $curr->convert($wpsc_cart->selected_shipping_amount, $google_curr, $local_currency_code);
        } else {
            $google_currency_productprice = wpsc_cart_item_price(false) / wpsc_cart_item_quantity() + wpsc_cart_item_shipping(false);
            $google_currency_shipping = $wpsc_cart->selected_shipping_amount;
        }
        //	exit('<pre>'.print_r(wpsc_cart_item_name(),true).'</pre>');
        $cartitem["{$no}"] = new GoogleItem(wpsc_cart_item_name(), '', wpsc_cart_item_quantity(), $google_currency_productprice);
        $cart->AddItem($cartitem["{$no}"]);
        $no++;
    }
    //If there are coupons applied add coupon as a product with negative price
    if ($wpsc_cart->coupons_amount > 0) {
        if ($google_curr != $local_currency_code) {
            $google_currency_productprice = $curr->convert($wpsc_cart->coupons_amount, $google_curr, $local_currency_code);
        } else {
            $google_currency_productprice = $wpsc_cart->coupons_amount;
        }
        $cartitem[$no] = new GoogleItem('Discount', 'Discount Price', 1, '-' . $google_currency_productprice);
        // Unit price
        $cart->AddItem($cartitem[$no]);
    }
    //	}
    // Add shipping options
    if (wpsc_uses_shipping() && $google_currency_shipping > 0) {
        $Gfilter = new GoogleShippingFilters();
        $google_checkout_shipping = get_option("google_shipping_country");
        $googleshippingcountries = count($google_checkout_shipping);
        //exit('<pre>'.print_r($googleshipping, true).'</pre>');
        if ($googleshippingcountries == 242) {
            $Gfilter->SetAllowedWorldArea(true);
        } else {
            if (is_array($google_checkout_shipping)) {
                $google_shipping_country_ids = implode(",", $google_checkout_shipping);
            }
            $google_shipping_country = $wpdb->get_col("SELECT `isocode` FROM " . WPSC_TABLE_CURRENCY_LIST . " WHERE id IN (" . $google_shipping_country_ids . ")");
            foreach ($google_shipping_country as $isocode) {
                //exit($isocode);
                $Gfilter->AddAllowedPostalArea($isocode);
                if ($isocode == 'US') {
                    $Gfilter->SetAllowedCountryArea('ALL');
                }
            }
        }
        $Gfilter->SetAllowUsPoBox(false);
        $ship_1 = new GoogleFlatRateShipping('Flat Rate Shipping', $google_currency_shipping);
        $ship_1->AddShippingRestrictions($Gfilter);
        $cart->AddShipping($ship_1);
    }
    //wpsc_google_shipping_quotes();
    // Add tax rules
    //if ($_SESSION['wpsc_selected_country']=='US'){
    //set default tax
    //exit('<pre>'.print_r($_SESSION,true).'</pre>');
    $sql = "SELECT `name`, `tax` FROM " . WPSC_TABLE_REGION_TAX . " WHERE id='" . $_SESSION['wpsc_selected_region'] . "'";
    //exit('<pre>'.print_r($sql, true).'</pre>');
    $state_name = $wpdb->get_row($sql, ARRAY_A);
    //exit('<pre>'.print_r($state_name, true).'</pre>');
    $defaultTax = $state_name['tax'] / 100;
    $tax_rule = new GoogleDefaultTaxRule($defaultTax);
    $sql = "SELECT `code` FROM " . WPSC_TABLE_REGION_TAX . " WHERE `country_id`='136' AND `tax` = " . $state_name['tax'];
    $states = $wpdb->get_col($sql);
    //exit('<pre>'.print_r($states, true).'</pre>');
    $tax_rule->SetStateAreas((array) $states);
    $cart->AddDefaultTaxRules($tax_rule);
    //get alternative tax rates
    $sql = "SELECT DISTINCT `tax` FROM " . WPSC_TABLE_REGION_TAX . " WHERE `tax` != 0 AND `tax` !=" . $state_name['tax'] . "  AND `country_id`='136' ORDER BY `tax`";
    $othertax = $wpdb->get_col($sql);
    $i = 1;
    //exit('<pre>'.print_r($othertax, true).'</pre>');
    foreach ($othertax as $altTax) {
        $sql = "SELECT `code` FROM " . WPSC_TABLE_REGION_TAX . " WHERE `country_id`='136' AND `tax`=" . $altTax;
        $alt = $wpdb->get_col($sql);
        $altTax = $altTax / 100;
        $alt_google_tax = new GoogleDefaultTaxRule($altTax);
        $alt_google_tax->SetStateAreas($alt);
        //$g = new GoogleAlternateTaxTable('Alt Tax'.$i);
        //$g->AddAlternateTaxRules($alt_google_tax);
        $cart->AddDefaultTaxRules($alt_google_tax);
        //			exit(print_r($alt,true));
        $i++;
    }
    //}
    if (get_option('google_button_size') == '0') {
        $google_button_size = 'BIG';
    } elseif (get_option('google_button_size') == '1') {
        $google_button_size = 'MEDIUM';
    } elseif (get_option('google_button_size') == '2') {
        $google_button_size = 'SMALL';
    }
    // Display Google Checkout button
    //echo '<pre>'.print_r($cart, true).'</pre>';
    //unset($_SESSION['wpsc_sessionid']);
    //if($fromCheckout){
    echo $cart->CheckoutButtonCode($google_button_size);
    //}
}
function Usecase($separator, $sessionid, $fromcheckout)
{
    global $wpdb, $wpsc_cart;
    $purchase_log_sql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` = %s  LIMIT 1", $sessionid);
    $purchase_log = $wpdb->get_results($purchase_log_sql, ARRAY_A);
    $cart_sql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = %d", $purchase_log[0]['id']);
    $wp_cart = $wpdb->get_results($cart_sql, ARRAY_A);
    $merchant_id = get_option('google_id');
    $merchant_key = get_option('google_key');
    $server_type = get_option('google_server_type');
    $currency = get_option('google_cur');
    $transact_url = get_option('transact_url');
    $returnURL = $transact_url . $separator . "sessionid=" . $sessionid . "&gateway=google";
    $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);
    $cart->SetContinueShoppingUrl($returnURL);
    $cart->SetEditCartUrl(get_option('shopping_cart_url'));
    //google prohibited items not implemented
    $currency_converter = new CURRENCYCONVERTER();
    $currency_code = $wpdb->get_results("SELECT `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . get_option('currency_type') . "' LIMIT 1", ARRAY_A);
    $local_currency_code = $currency_code[0]['code'];
    $google_curr = get_option('google_cur');
    $currentcy_rate = 1;
    if ($google_curr != $local_currency_code) {
        $currentcy_rate = $currency_converter->convert(1, $local_currency_code, $google_curr);
    }
    while (wpsc_have_cart_items()) {
        wpsc_the_cart_item();
        $google_currency_productprice = $currentcy_rate * (wpsc_cart_item_price(false) / wpsc_cart_item_quantity());
        $cart_item = new GoogleItem(wpsc_cart_item_name(), '', wpsc_cart_item_quantity(), $google_currency_productprice);
        $cart->AddItem($cart_item);
    }
    //If there are coupons applied add coupon as a product with negative price
    if ($wpsc_cart->coupons_amount > 0) {
        $google_currency_productprice = $currentcy_rate * $wpsc_cart->coupons_amount;
        $coupon = new GoogleItem('Discount', 'Discount Price', 1, '-' . $google_currency_productprice);
        $cart->AddItem($coupon);
    }
    $shipping_country = $purchase_log[0]['shipping_country'];
    $shipping_region = $purchase_log[0]['shipping_region'];
    if ($shipping_country == "UK") {
        $shipping_country = "GB";
    }
    // Add shipping options
    if (wpsc_uses_shipping()) {
        $shipping_name = ucfirst($wpsc_cart->selected_shipping_method) . " - " . $wpsc_cart->selected_shipping_option;
        if ($shipping_name == "") {
            $shipping_name = "Calculated";
        }
        $shipping = new GoogleFlatRateShipping($shipping_name, $wpsc_cart->calculate_total_shipping() * $currentcy_rate);
        if (!empty($shipping_country)) {
            $shipping_filter = new GoogleShippingFilters();
            if (!empty($shipping_region) && is_numeric($shipping_region)) {
                $shipping_filter->AddAllowedPostalArea($shipping_country, wpsc_get_state_by_id($shipping_region, "code"));
                $shipping_filter->AddAllowedStateArea(wpsc_get_state_by_id($shipping_region, "code"));
            } else {
                $shipping_filter->AddAllowedPostalArea($shipping_country);
            }
            $shipping->AddShippingRestrictions($shipping_filter);
        }
        $cart->AddShipping($shipping);
    }
    // Add tax rules
    if (!empty($shipping_country)) {
        $tax_rule = new GoogleDefaultTaxRule(wpsc_cart_tax(false) / $wpsc_cart->calculate_subtotal());
        $tax_rule->AddPostalArea($shipping_country);
        $cart->AddDefaultTaxRules($tax_rule);
    }
    // Display Google Checkout button
    if (get_option('google_button_size') == '0') {
        $google_button_size = 'BIG';
    } elseif (get_option('google_button_size') == '1') {
        $google_button_size = 'MEDIUM';
    } elseif (get_option('google_button_size') == '2') {
        $google_button_size = 'SMALL';
    }
    echo $cart->CheckoutButtonCode($google_button_size);
}
        public function checkout_ids()
        {
            if (wpsc_cart_item_count() > 0) {
                global $wpsc_cart;
                $line_items = array();
                while (wpsc_have_cart_items()) {
                    wpsc_the_cart_item();
                    $current_item = $wpsc_cart->cart_item;
                    $parent = $this->get_parent_post($current_item->product_id);
                    if ($parent) {
                        $product_id = $parent->ID;
                        $product_name = $parent->post_title;
                    } else {
                        $product_id = wpsc_cart_item_product_id();
                        $product_name = wpsc_cart_item_name();
                    }
                    $line_item = (int) $product_id;
                    $line_items[] = $line_item;
                }
                echo '<script type="text/javascript">
			        var _ra = _ra || {};
			 	    _ra.checkoutIdsInfo =' . json_encode($line_items, JSON_PRETTY_PRINT) . '
			        if (_ra.ready !== undefined) {
				        _ra.checkoutIds(_ra.checkoutIdsInfo);
				  }
			</script>';
            }
        }