<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SIM line item integration in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24041#M12913</link>
    <description>&lt;P&gt;If you can do a print_r() of the item array from your cart, I can maybe write something to adapt that for you.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Mar 2012 05:50:28 GMT</pubDate>
    <dc:creator>TJPride</dc:creator>
    <dc:date>2012-03-06T05:50:28Z</dc:date>
    <item>
      <title>SIM line item integration</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24029#M12907</link>
      <description>&lt;P&gt;I've searched the forums for help on getting line item data to display via SIM method. &amp;nbsp;I've been able to hardcode the data in and it works just fine, but I need to pull from the shopping cart as it is obviously going to be dynamic and possibly have multiple items.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far this is what I have come up with that works to display one item, but not multiple...&lt;/P&gt;&lt;PRE&gt;&amp;lt;input type='hidden' name="x_line_item" value="&amp;lt;?php echo $prodslistpostID; ?&amp;gt;&amp;lt;|&amp;gt;&amp;lt;?php echo $prodslistitem; ?&amp;gt;&amp;lt;|&amp;gt;&amp;lt;|&amp;gt;&amp;lt;?php echo $prodslistquantity; ?&amp;gt;&amp;lt;|&amp;gt;&amp;lt;?php echo $prodslistamount; ?&amp;gt;&amp;lt;|&amp;gt;Y" /&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Any help would be amazing.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2012 22:56:37 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24029#M12907</guid>
      <dc:creator>k2</dc:creator>
      <dc:date>2012-03-05T22:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: SIM line item integration</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24033#M12909</link>
      <description>&lt;P&gt;Here's some code I hacked together quickly. This simulates an array of two items.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;?php
$items = array(
    array(
        'id' =&amp;gt; 'ID1',
        'name' =&amp;gt; 'Product Name 1',
        'description' =&amp;gt; 'Product Description 1',
        'quantity' =&amp;gt; 1,
        'price' =&amp;gt; '9.99',
        'taxable' =&amp;gt; 'Y'
    ),
    array(
        'id' =&amp;gt; 'ID2',
        'name' =&amp;gt; 'Product Name 2',
        'description' =&amp;gt; 'Product Description 2',
        'quantity' =&amp;gt; 1,
        'price' =&amp;gt; '4.99',
        'taxable' =&amp;gt; 'Y'
    )
);

foreach ($items as $item) {
    $line_item = array();
    foreach (array('id', 'name', 'description', 'quantity', 'price', 'taxable') as $key)
        $line_item[] = $item[$key];
    print '&amp;lt;input type="hidden" name="x_line_item" value="' .
          implode('&amp;lt;|&amp;gt;', $line_item) .
          '"&amp;gt;' . "\n";
}
?&amp;gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Mar 2012 00:57:23 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24033#M12909</guid>
      <dc:creator>TJPride</dc:creator>
      <dc:date>2012-03-06T00:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: SIM line item integration</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24039#M12912</link>
      <description>&lt;P&gt;Thanks for your help TJ. &amp;nbsp;I think this is getting towards what I need, but not there yet. &amp;nbsp;Basically, I need something that can pull items that have been added to the shopping cart and then post them to the Authorize.net hosted checkout page. &amp;nbsp;This could be anywhere from 1 item to 30 items (so I would need the arrays to generate dynamically as well). &amp;nbsp;I'm using Wordpress with MarketTheme if that helps any.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Mar 2012 01:30:05 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24039#M12912</guid>
      <dc:creator>k2</dc:creator>
      <dc:date>2012-03-06T01:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: SIM line item integration</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24041#M12913</link>
      <description>&lt;P&gt;If you can do a print_r() of the item array from your cart, I can maybe write something to adapt that for you.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Mar 2012 05:50:28 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24041#M12913</guid>
      <dc:creator>TJPride</dc:creator>
      <dc:date>2012-03-06T05:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: SIM line item integration</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24049#M12917</link>
      <description>&lt;P&gt;Here is what I got. Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Array ( [423] =&amp;gt; Array ( [postID] =&amp;gt; 423 [quantity] =&amp;gt; 1 [shipping] =&amp;gt; 4.95 [shipping2] =&amp;gt; 0 ) [368] =&amp;gt; Array ( [postID] =&amp;gt; 368 [quantity] =&amp;gt; 1 [shipping] =&amp;gt; 4.95 [shipping2] =&amp;gt; 0 ) ) Array ( [423] =&amp;gt; Array ( [postID] =&amp;gt; 423 [quantity] =&amp;gt; 1 [shipping] =&amp;gt; 4.95 [shipping2] =&amp;gt; 0 ) [368] =&amp;gt; Array ( [postID] =&amp;gt; 368 [quantity] =&amp;gt; 1 [shipping] =&amp;gt; 4.95 [shipping2] =&amp;gt; 0 ) )&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Mar 2012 15:35:27 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24049#M12917</guid>
      <dc:creator>k2</dc:creator>
      <dc:date>2012-03-06T15:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: SIM line item integration</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24055#M12920</link>
      <description>&lt;P&gt;It's more helpful to view source so it's indented properly, and did you paste or output the same thing twice?&lt;/P&gt;&lt;P&gt;But in any case:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;?php
$items = Array( 
	'423' =&amp;gt; Array( 
		'postID' =&amp;gt; 423,
		'quantity' =&amp;gt; 1,
		'shipping' =&amp;gt; 4.95,
		'shipping2' =&amp;gt; 0,
	),
	'368' =&amp;gt; Array( 
		'postID' =&amp;gt; 368,
		'quantity' =&amp;gt; 1,
		'shipping' =&amp;gt; 4.95,
		'shipping2' =&amp;gt; 0
	)
);

foreach ($items as $item) {
    $line_item = array();
    
    if (!$item['taxable'])
        $item['taxable'] = 'Y';

    $item['price'] += $item['shipping'] + $item['shipping2'];
    
    foreach (array('postID', 'name', 'description', 'quantity', 'price', 'taxable') as $key)
        $line_item[] = $item[$key];

    print '&amp;lt;input type="hidden" name="x_line_item" value="' .
          implode('&amp;lt;|&amp;gt;', $line_item) .
          '"&amp;gt;' . "\n";
}
?&amp;gt;&lt;/PRE&gt;&lt;P&gt;Outputs:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;input type="hidden" name="x_line_item" value="423&amp;lt;|&amp;gt;&amp;lt;|&amp;gt;&amp;lt;|&amp;gt;1&amp;lt;|&amp;gt;4.95&amp;lt;|&amp;gt;Y"&amp;gt;
&amp;lt;input type="hidden" name="x_line_item" value="368&amp;lt;|&amp;gt;&amp;lt;|&amp;gt;&amp;lt;|&amp;gt;1&amp;lt;|&amp;gt;4.95&amp;lt;|&amp;gt;Y"&amp;gt;&lt;/PRE&gt;&lt;P&gt;You ought to be able to take it from here. If not, study the PHP manual:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.php.net/manual/en/" target="_blank"&gt;http://www.php.net/manual/en/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Mar 2012 16:58:59 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24055#M12920</guid>
      <dc:creator>TJPride</dc:creator>
      <dc:date>2012-03-06T16:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: SIM line item integration</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24089#M12931</link>
      <description>&lt;P&gt;Unfortunately I'm still not any closer. &amp;nbsp;I'm sure I didn't explain my problem well. &amp;nbsp;Below is the code from my shopping cart. &amp;nbsp;Somehow I need to grab the line item info from here and post it to the authorize.net form.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;?php
session_start();

error_reporting (E_ALL ^ E_NOTICE);

	$load = '../../../../wp-load.php';
	if (file_exists($load)){
		require($load);
	} else {
		wp_die('Error: wp-load file not found');
	}
	
// Get Session variable data
$LANGUAGE = $_SESSION["LANGUAGE"];
$CURRENCY_SYMBOL = $_SESSION["CURRENCY_SYMBOL"];
$CURRENCY_CODE = $_SESSION["CURRENCY_CODE"];
$PPEmail = $_SESSION["PPEmail"];
$CARTDIR = $_SESSION["CARTDIR"];
$CARTURL = $CARTDIR . "cart.php";
$CHECKOUT_RETURNURL = $_SESSION["POSTSALE_URL"];

require("../language/" . $LANGUAGE . ".php");

// Payment Processing Post URL -- (Enable only one)
$ACTION_URL = "&lt;A href="https://www.paypal.com/cgi-bin/webscr" target="_blank"&gt;https://www.paypal.com/cgi-bin/webscr&lt;/A&gt;";  //Paypal 
//$ACTION_URL = "&lt;A href="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/YOURMERCHANTIDHERE" target="_blank"&gt;https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/YOURMERCHANTIDHERE&lt;/A&gt;";  //Google Checkout (change merch ID)


//TODO: Create Cart Object
$crtQuantity = array();
$crtStockQuantity = array();
$crtAmount = array();
$crtShipping = array();
$crtShipping2 = array();
$crtHandling = array();
$crtHandlingCart = array();
$crtOptions = array();
$PPOptions = array();

//retrieve session Variables
if($_SESSION["Quantity"]){
	$crtName = $_SESSION["Name"];
	$crtNotes = $_SESSION["Notes"];
	$crtPostID = $_SESSION["PostID"];
	$crtQuantity = $_SESSION["Quantity"];
	$crtStockQuantity = $_SESSION["StockQuantity"];
	$crtAmount = $_SESSION["Amount"];
	$crtShipping = $_SESSION["Shipping"];
	$crtShipping2 = $_SESSION["Shipping2"];
	$crtHandling = $_SESSION["Handling"];
	$crtHandlingCart = $_SESSION["HandlingCart"];
	$crtOptions = $_SESSION["Options"];
	$PPOptions = $_SESSION["PPOptions"];
}

//convert strings to integers
function str2int($string, $concat = true) {
    $length = strlen($string);   
    for ($i = 0, $int = '', $concat_flag = true; $i &amp;lt; $length; $i++) {
        if (is_numeric($string[$i]) &amp;amp;&amp;amp; $concat_flag) {
            $int .= $string[$i];
        } elseif(!$concat &amp;amp;&amp;amp; $concat_flag &amp;amp;&amp;amp; strlen($int) &amp;gt; 0) {
            $concat_flag = false;
        }       
    }
   
    return (int) $int;
}

//Save Session Variables
function SaveSession($crtName,$crtNotes,$crtPostID,$crtAmount,$crtQuantity,$crtStockQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions=' '){
	$_SESSION["Name"] = $crtName;
	$_SESSION["Notes"] = $crtNotes;
	$_SESSION["PostID"] = $crtPostID;
	$_SESSION["Quantity"] = $crtQuantity;
	$_SESSION["StockQuantity"] = $crtStockQuantity;
	$_SESSION["Amount"] = $crtAmount;
	$_SESSION["Shipping"] = $crtShipping;
	$_SESSION["Shipping2"] = $crtShipping2;
	$_SESSION["Handling"] = $crtHandling;
	$_SESSION["HandlingCart"] = $crtHandlingCart;
	$_SESSION["Options"] = $crtOptions;
	$_SESSION["PPOptions"] = $PPOptions;
	
}


//Monolithic display cart function
function ShowCart($crtName,$crtNotes,$crtPostID,$crtAmount,$crtQuantity,$crtStockQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions){
	include("cart_top.php");
	
	global $CARTURL,$CURRENCY_SYMBOL,$ACTION_URL,$CHECKOUT_RETURNURL,$CARTDIR;

	$checkout = '';
	$prods = '';
	$i = 1;
	$ShippingTotal = 0;
	$GrandTotal = 0;
		// Calculation of $ShippingTotal - starts
		if(!empty($crtPostID))
		{
			$s_values = array();
			foreach( $crtPostID as $item =&amp;gt;$postid )
			{
				$r = array_key_exists($postid,$s_values);
				if(!$r)
				{
					$s_values[$postid]['postID'] = $crtPostID[$item];
					$s_values[$postid]['quantity'] = $crtQuantity[$item];
					$s_values[$postid]['shipping'] = $crtShipping[$item];
					$s_values[$postid]['shipping2'] = $crtShipping2[$item];												
				}
				else
				{
					$s_values[$postid]['quantity'] = $s_values[$postid]['quantity'] + $crtQuantity[$item];
				}
			}
			$ShippingTotal = 0;
			foreach( $s_values as $postid =&amp;gt;$v )
			{
				if ($v['quantity'] &amp;gt; 1)
				{
					$ShippingTotal = $ShippingTotal + $v['shipping'];
					$ShippingTotal = $ShippingTotal + (($v['quantity'] - 1) * $v['shipping2']);
				}
				else
				{
					$ShippingTotal = $ShippingTotal + $v['shipping'];
				}
			}
		}	// End 
		// Calculation of $ShippingTotal - ends
		
		foreach( $crtAmount as $item =&amp;gt;$amount )
		{
			$GrandTotal = $GrandTotal + ($crtAmount[$item] * $crtQuantity[$item]);			
			
			// Display Comments/Special Instructions Box value
			$sp_comments = '';
			if (!empty($crtNotes[$item]))
			{
				$sp_comments = '&amp;lt;br&amp;gt;&amp;lt;div style="margin-left: 10px;"&amp;gt;&amp;lt;small&amp;gt;&amp;lt;a title="'.$crtNotes[$item].'"&amp;gt;'.mkt_SHOPCART_ITEM_SPECIAL_INSTRUCTIONS.'&amp;lt;/a&amp;gt;&amp;lt;/small&amp;gt;&amp;lt;/div&amp;gt;';
			}
			
			$mkt_pk_item_amount = $CURRENCY_SYMBOL.number_format((float)($crtAmount[$item] * $crtQuantity[$item]), 2, '.', ',');
			
			$Shipping = 'Shipping: '.$CURRENCY_SYMBOL.$Shipping;
			$content .= '&amp;lt;tr id="'.$item.'"&amp;gt;&amp;lt;td&amp;gt;'.$crtName[$item].$sp_comments.'&amp;lt;/td&amp;gt;&amp;lt;td style="text-align:left;"&amp;gt;'.$crtOptions[$item].'&amp;lt;/td&amp;gt;&amp;lt;td style="text-align:center;"&amp;gt;&amp;lt;input class="quantity" name="'.$item.'" type="text" value="'.$crtQuantity[$item].'" /&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td style="text-align:center;"&amp;gt;&amp;lt;a href="'.$GLOBALS["CARTURL"].'?remove='.$item.'" class="crtRemove"&amp;gt;'.mkt_SHOPCART_ITEM_REMOVE.'&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td style="text-align:right;"&amp;gt;'.$mkt_pk_item_amount.'&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
			
				if ($crtHandling[$item]){
					$Handling = $crtHandling[$item];
						if($crtQuantity[$item] &amp;gt; 1){ 
							$Handling += $crtHandlingCart[$item] * ($crtQuantity[$item] - 1);
						}
					$checkout .='&amp;lt;input type="hidden" name="handling_'.$i.'" value="'.$Handling.'" /&amp;gt;';
				}
			
			$checkout .='&amp;lt;input type="hidden" name="item_name_'.$i.'" value="'.$crtName[$item].'" /&amp;gt;
		        &amp;lt;input type="hidden" name="amount_'.$i.'" value="'.$crtAmount[$item].'" /&amp;gt;
		        &amp;lt;input type="hidden" name="quantity_'.$i.'" value="'.$crtQuantity[$item].'" /&amp;gt;';

			// The following 4 inputs are for Google Checkout purposes
			$checkout .='&amp;lt;input type="hidden" name="item_description_'.$i.'" value="'.$crtOptions[$item].'" /&amp;gt;
						&amp;lt;input type="hidden" name="item_quantity_'.$i.'" value="'.$crtQuantity[$item].'" /&amp;gt;
						&amp;lt;input type="hidden" name="item_price_'.$i.'" value="'.$crtAmount[$item].'" /&amp;gt;
						&amp;lt;input type="hidden" name="item_currency_'.$i.'" value="'.$GLOBALS["CURRENCY_CODE"].'" /&amp;gt;';
					

			// Shipping Calculation for each item - STARTS
			$item_shipping_pk = 0;
			$mkt_post_id_temp = $crtPostID[$item];
			if($s_values[$mkt_post_id_temp]['quantity'] &amp;gt; 1)
			{
				$item_shipping_pk = $item_shipping_pk + $s_values[$mkt_post_id_temp]['shipping'];
				$item_shipping_pk = $item_shipping_pk + (($s_values[$mkt_post_id_temp]['quantity'] - 1) * $s_values[$mkt_post_id_temp]['shipping2']);				
			}
			else
			{
				$item_shipping_pk = $item_shipping_pk + $s_values[$mkt_post_id_temp]['shipping'];
			}
			
			// Shipping Calculation for each item - ENDS
              
// Set shipping to only 1st item charge
if ($i==1){
     $ShippingTotal = $crtShipping[$item];
} 

// Create value for inventory control			  
				$mkt_pk_item_amount = (float)($crtAmount[$item] * $crtQuantity[$item]);
				$prods = $prods . $crtPostID[$item] . "+:#" . $crtName[$item]. "+:#". $crtOptions[$item]. "+:#" . $crtQuantity[$item]. "+:#" . $mkt_pk_item_amount. "+:#" . $crtNotes[$item] . "+:#";
				if ($i &amp;lt; count($crtPostID)) {
					// set item shipping to zero, and add separator
					$prods = $prods . "0" . "^:*";
				} else {
					// add total order shipping to last product record
					$prods = $prods . $ShippingTotal; 
				}
				
			++$i;			
		}
		
		// If no item value, then display message
		if ($item == null){
			$content .= '&amp;lt;tr&amp;gt;&amp;lt;td colspan=5&amp;gt;'.mkt_SHOPCART_NOITEMS.'&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
		}

	$ItemSubTotal = $GrandTotal;
	$GrandTotal = $GrandTotal + $ShippingTotal;

   //session_register("grand_total"); 
  	$_SESSION["grand_total"] = $GrandTotal;
   //session_register("item_subtotal"); 
  	$_SESSION["item_subtotal"] = $ItemSubTotal;
   //session_register("shipping_cost"); 
  	$_SESSION["shipping_cost"] = $ShippingTotal;
		
	$content .='
		&amp;lt;input type="hidden" name="grand_total" value="'.$GrandTotal.'" /&amp;gt;
		&amp;lt;input type="hidden" name="item_subtotal" value="'.$ItemSubTotal.'" /&amp;gt;
		&amp;lt;input type="hidden" name="shipping_cost" value="'.$ShippingTotal.'" /&amp;gt;
	';
	
	$mkt_pk_ItemSubTotal = $CURRENCY_SYMBOL.number_format($ItemSubTotal, 2, '.', ',');
	$mkt_pk_ShippingTotal = $CURRENCY_SYMBOL.number_format($ShippingTotal, 2, '.', ',');
	$mkt_pk_GrandTotal = $CURRENCY_SYMBOL.number_format($GrandTotal, 2, '.', ',');


	$content .= '&amp;lt;tr&amp;gt;';
	
	if((isset($_REQUEST['coupon'])) OR ($_SESSION['discount_code'])){
		if (trim($_REQUEST['coupon'])) { 
			$coupon = trim($_REQUEST['coupon']);
		} else {
			$coupon = $_SESSION['discount_code'];
		}
		$new_value = mkt_calc_coupon($coupon,$ItemSubTotal);

	  	if($new_value == false){
			$show_coupon_text .= '&amp;lt;font color="red"&amp;gt;'.mkt_SHOPCART_OPTIONS_COUPON_INVALID.'&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;';
			$_SESSION['discount_value'] = '';
			$_SESSION['discount_code'] = '';
		}else{
			$less = $GrandTotal - $ShippingTotal - $new_value;
			$DiscountGrandTotal = $new_value + $ShippingTotal;
			$_SESSION["grand_total"] = $DiscountGrandTotal;
			$mkt_pk_GrandTotal = $CURRENCY_SYMBOL.number_format($DiscountGrandTotal, 2, '.', ',');	
			$show_coupon_text .= '&amp;lt;font color="green"&amp;gt;'.mkt_SHOPCART_OPTIONS_COUPON_APPLIED_SUCCESS.'&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;';
			$content .='&amp;lt;input type="hidden" name="discount_amount_cart" value="'.$less.'" /&amp;gt;';
			$_SESSION['discount_value'] = $less;
			$_SESSION['discount_code'] = $coupon;
		}
	}

	$show_coupon_text = '&amp;lt;td colspan="2" valign="top"&amp;gt;&amp;lt;br&amp;gt;'.mkt_SHOPCART_OPTIONS_COUPON_PROMO_CODE.' &amp;lt;input type="text" name="coupon" value="'.$coupon.'" style="width:110px;"/&amp;gt;&amp;lt;br&amp;gt;'.$show_coupon_text;
	$show_coupon_text .=  '&amp;lt;/td&amp;gt;';
	
	$content .= $show_coupon_text;
	if ($_SESSION['discount_value']) {
		$coupon_text1 = "&amp;lt;font color='green'&amp;gt;".mkt_SHOPCART_OPTIONS_COUPON_APPLIED_SUCCESS2."&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;";
		$coupon_text2 = "&amp;lt;font color='green'&amp;gt;-".$CURRENCY_SYMBOL.number_format($_SESSION['discount_value'], 2, '.', ',')."&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;";
	}

	
	$content .= '&amp;lt;td colspan="2" style="text-align: right;"&amp;gt;'.mkt_SHOPCART_SUBTOTAL.'&amp;lt;br/&amp;gt;'.$coupon_text1.mkt_SHOPCART_SHIPPING.'&amp;lt;br/&amp;gt;&amp;lt;b&amp;gt;'.mkt_SHOPCART_TOTAL.'&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td style="text-align:right;"&amp;gt;'.$mkt_pk_ItemSubTotal.'&amp;lt;br/&amp;gt;'.$coupon_text2.$mkt_pk_ShippingTotal.'&amp;lt;br/&amp;gt;&amp;lt;b&amp;gt;'.$mkt_pk_GrandTotal.'&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;';

	$content .= '&amp;lt;/tr&amp;gt;';
	
	// Create product summary session variable for inventory control postsale page
	$_SESSION["prods"] = $prods;
	$_SESSION["mkt_pk_ItemSubTotal"] = $mkt_pk_ItemSubTotal;
	$_SESSION["mkt_pk_ShippingTotal"] = $mkt_pk_ShippingTotal;
	$_SESSION["mkt_pk_GrandTotal"] = $mkt_pk_GrandTotal;

	$content .='
		&amp;lt;input type="hidden" name="prods" value="'.$prods.'" /&amp;gt;
		&amp;lt;input type="hidden" name="mkt_pk_ItemSubTotal" value="'.$mkt_pk_ItemSubTotal.'" /&amp;gt;
		&amp;lt;input type="hidden" name="mkt_pk_ShippingTotal" value="'.$mkt_pk_ShippingTotal.'" /&amp;gt;
		&amp;lt;input type="hidden" name="mkt_pk_GrandTotal" value="'.$mkt_pk_GrandTotal.'" /&amp;gt;		
	';
	
	// The following 4 inputs are Google Checkout variables
		$checkout .='&amp;lt;input type="hidden" name="ship_method_name_1" value="Ship Method"/&amp;gt;';
		$checkout .='&amp;lt;input type="hidden" name="ship_method_price_1" value="'.$ShippingTotal.'" /&amp;gt;';
		$checkout .='&amp;lt;input type="hidden" name="ship_method_currency_1" value="'.$GLOBALS["CURRENCY_CODE"].'" /&amp;gt;';			
		$checkout .='&amp;lt;input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.continue-shopping-url" value="' . $CHECKOUT_RETURNURL . '"&amp;gt;';

	// Send the ADMIN EMAIL address too...
		$checkout .='&amp;lt;input type="hidden" name="mkt_pk_admin_email" value="'.$_SESSION["mkt_pk_admin_email"].'"/&amp;gt;';

	include("cart_bottom.php");
	echo $content;
}

if($_GET['cart']){
		ShowCart($crtName,$crtNotes,$crtPostID,$crtAmount,$crtQuantity,$crtStockQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions);
}

if($_GET["remove"]){
	$item = removeItem($_GET["remove"]);
}

function removeItem($item){
	global $crtName,$crtNotes,$crtPostID,$crtAmount,$crtQuantity,$crtStockQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions;
	unset($crtName[$item]);
	unset($crtNotes[$item]);
	unset($crtPostID[$item]);
	unset($crtAmount[$item]);
	unset($crtQuantity[$item]);
	unset($crtStockQuantity[$item]);
	unset($crtShipping[$item]);
	unset($crtShipping2[$item]);
	unset($crtHandling[$item]);
	unset($crtHandlingCart[$item]);
	unset($crtOptions[$item]);
	SaveSession($crtName,$crtNotes,$crtPostID,$crtAmount,$crtQuantity,$crtStockQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions);
	return $item;
}

if($_GET["update"]){
	foreach ($_GET as $item =&amp;gt; $value ){
	
		if($crtQuantity[$item]){
			if (($crtStockQuantity[$item] != "") &amp;amp;&amp;amp; ($value &amp;gt; $crtStockQuantity[$item])) {
				echo "&amp;lt;span style='color:#F00000;'&amp;gt;&amp;lt;b&amp;gt;" . mkt_SHOPCART_OVERSTOCK_MESSAGE . " " . $crtStockQuantity[$item] . " -- (" . $crtName[$item]  . ")&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;br&amp;gt;";
				$crtQuantity[$item] = $crtStockQuantity[$item];
			} else {
				$crtQuantity[$item] = str2int($value);
			}			
			// If value = 0 then remove item from list
			if($crtQuantity[$item] == 0){
				removeItem($item);
			} 
		 }
	}
	SaveSession($crtName,$crtNotes,$crtPostID,$crtAmount,$crtQuantity,$crtStockQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions);
	ShowCart($crtName,$crtNotes,$crtPostID,$crtAmount,$crtQuantity,$crtStockQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions);
}


if($_GET["add"]){
	$item ="item".rand();//An Id can be used in lue of store with multiple items with the same name
	$name = $_GET["item_name"];
	$notes = $_GET["notes"];
	$postID = $_GET["postID"];
	$amt = (float)$_GET["amount"];
	$handling = (float)$_GET["handling"];
	$handling_cart = (float)$_GET["handling_cart"];
	$quan = str2int($_GET["quantity"]);
	$stockquantity = str2int($_GET["stockquantity"]);
	$ppoptions = "";
	$optionpricing = 0;
	
	$options = "";
	$i = 0;

	if(strpos($_GET["shipping"],"/")){
		$ar = explode("/",$_GET["shipping"]);
		$ship = (float)$ar[0];
		$ship2= (float)$ar[1];
	}else{
		$ship = (float)$_GET["shipping"];
		$ship2= 0;
	}
	
	foreach ($_GET as $key =&amp;gt; $value ){
		$val = substr($key,0,2);
			if($val=="on"){
				$opt = substr($key,2,1);
				$index = "os".$opt;

				// Option pricing begin
				$optionval = explode("@",$_GET[$index]);
				$optionpricing = $optionpricing + $optionval[1];
				if ($optionval[1]) {
					if ($optionval[1]&amp;gt;0) {
						$optiontext = " (+"; 
					} else {
						$optiontext = " (-"; 
					}
					$optiontext = $optiontext . $CURRENCY_SYMBOL.number_format(abs($optionval[1]), 2, '.', ','); 
					$optiontext = $optiontext .")";
				} else {
					$optiontext = "";
				}
				// Option pricing end			

				$options.= $value.': '.$optionval[0].$optiontext.'&amp;lt;br /&amp;gt;';
				++$i;
			}
	}
		
	// Check for duplicate products
		if ($crtPostID == "") {$crtPostID = array();}
		$duplicate_prodIDs = array_keys($crtPostID, $postID);
		for($i=0; $i&amp;lt;count($duplicate_prodIDs); $i++)
		{
			$totalprodquan += $crtQuantity[$duplicate_prodIDs[$i]];
			$s1 = trim($notes);
			$s2 = trim($crtNotes[$duplicate_prodIDs[$i]]);
			$cmp = strcasecmp($s1, $s2);
			if (($postID == $crtPostID[$duplicate_prodIDs[$i]]) &amp;amp;&amp;amp; ($options == $crtOptions[$duplicate_prodIDs[$i]]) &amp;amp;&amp;amp; ($cmp == 0)) 
			{
				$duplicateitemID = $duplicate_prodIDs[$i];
			}
		}


	// Check to see if this puts it over stock quantity
	if (($stockquantity !="") &amp;amp;&amp;amp; ($totalprodquan + $quan &amp;gt; $stockquantity)) {
		echo "&amp;lt;span style='color:#F00000;'&amp;gt;&amp;lt;b&amp;gt;" . mkt_SHOPCART_OVERSTOCK_MESSAGE . " " . $stockquantity . " -- (" . $name  . ")&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;br&amp;gt;";
	} else {
		if ($duplicateitemID) {
					$crtQuantity[$duplicateitemID] += $quan;
					$crtNotes[$duplicateitemID] = $notes;	
				//if($crtShipping[$item] &amp;lt; $ship){
					$crtShipping[$item] = $ship;
					$crtShipping2[$item] = $ship2;
					$crtHandling[$item] = $handling;
					$crtHandlingCart[$item] = $handling_cart;
				//}
		}else{// A new item
			$crtName[$item] = $name;
			$crtNotes[$item] = $notes;			
			$crtPostID[$item] = $postID;
			$crtAmount[$item] = $amt + $optionpricing;
			$crtShipping[$item] = $ship;
			$crtShipping2[$item] = $ship2;
			$crtHandling[$item] = $handling;
			$crtHandlingCart[$item] = $handling_cart;
			$crtQuantity[$item] = $quan;
			$crtStockQuantity[$item] = $stockquantity;
			$crtOptions[$item] = $options;
			$PPOptions[$item] = $ppoptions;
		}
	}
	//Save the Session and Display the cart
	SaveSession($crtName,$crtNotes,$crtPostID,$crtAmount,$crtQuantity,$crtStockQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions);
	ShowCart($crtName,$crtNotes,$crtPostID,$crtAmount,$crtQuantity,$crtStockQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions);
}

//***************** Function for Coupon Management - S T A R T S *******************
function mkt_calc_coupon($coupon,$order_total) {

	// This function will return false, in case of any error
	// Or will return value of the coupon
	
	global $mkt_options;
	global $wpdb;
	global $mkt_db_version;
	global $mkt_db_error;
	$mkt_db_error = '';

	$table_name = $wpdb-&amp;gt;prefix . "mkt_coupon";
	$coupon = trim($coupon);
	$r = $wpdb-&amp;gt;get_row("SELECT * FROM $table_name WHERE coupon = '$coupon'");
	
	if(!$r){ 
		 return false; 
	}
	
	// Check if start date valid yet. If no, return false.
	if($r-&amp;gt;start_type == 'date'){
		$today_timestamp = mktime(0,0,0, date('m'), date('d'), date('Y'));
		if ($today_timestamp &amp;lt; $r-&amp;gt;start_date ){ 
			 return false; 
		}
	}
	
	// Check if it is expired. If yes, return false.
	if($r-&amp;gt;expiry_type == 'day'){
		$creation_timestamp = $r-&amp;gt;creation_date ;
		$expiry_timestamp = mktime(0,0,0,date('m', $creation_timestamp), (date('d', $creation_timestamp) + $r-&amp;gt;num_of_days) , date('Y', $creation_timestamp));
		$today_timestamp = mktime(0,0,0, date('m'), date('d'), date('Y'));
		if ($today_timestamp &amp;gt; $expiry_timestamp){ 
			 return false; 
		}
	}
	elseif($r-&amp;gt;expiry_type == 'date'){
		$today_timestamp = mktime(0,0,0, date('m'), date('d'), date('Y'));
		if ($today_timestamp &amp;gt;= $r-&amp;gt;expiry_date ){ 
			 return false; 
		}
	}

	if($r-&amp;gt;type == 'amount'){
		$discounted_amount = $order_total - $r-&amp;gt;value;
	}
	elseif($r-&amp;gt;type == 'percent'){
		$discounted_amount = $order_total - ($order_total * $r-&amp;gt;value /100);
	}
	
	return $discounted_amount;
	
}
//***************** Function for Coupon Management - E N D S *******************


?&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2012 00:55:32 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24089#M12931</guid>
      <dc:creator>k2</dc:creator>
      <dc:date>2012-03-07T00:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: SIM line item integration</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24091#M12932</link>
      <description>&lt;P&gt;If you don't feel up to modifying the cart yourself, I would advise either asking the makers of the cart for help, or hiring an Authorize.net developer:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.authorize.net/solutions/merchantsolutions/merchantservices/certifieddeveloperdirectory/" target="_blank"&gt;http://www.authorize.net/solutions/merchantsolutions/merchantservices/certifieddeveloperdirectory/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can only help so much in the limited amount of time I have to post.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2012 03:28:57 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/SIM-line-item-integration/m-p/24091#M12932</guid>
      <dc:creator>TJPride</dc:creator>
      <dc:date>2012-03-07T03:28:57Z</dc:date>
    </item>
  </channel>
</rss>

