This integration method will help you to integrate Post Affiliate Pro with Interspire Shopping Cart 6.0+ in case when customers are not returned on the Interspire thank you page after payment with Google Checkout.

1.

What is this script for?

This setup was created to track products ordered in InterspireShopping Cart and paid with Google Checkout. What this script does is that it posts each different product ordered as a separate sale to PAP4 or whole cart as a one sale. For sale tracking PAP API tracking is used.

2.

Adding visitorId field into ProductAddToCart template

Edit file /templates/__master/Snippets/ProductAddToCart.html
(if you have changed it in own template it is in directory: /templates/[used template]/Snippets/)

Add this row into form (after row <input type="hidden" name="currency_id" value="" />):

<input value="" name="product-private-data" type="hidden" id="pap_dx8vc2s5">


and after end of form tag "</form>"
add:
<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/notifysale.php" type="text/javascript">
</script>


Code below shows whole ProductAddToCart.html file after changes:

%%GLOBAL_AddToCartButtonControlScript%%
<form method="post" action="%%GLOBAL_CartLink%%" onsubmit="return check_add_to_cart(this, %%GLOBAL_ProductOptionRequired%%)"  enctype="multipart/form-data">
	<input type="hidden" name="action" value="add" />
	<input type="hidden" name="product_id" value="%%GLOBAL_ProductId%%" />
	<input type="hidden" name="variation_id" class="CartVariationId" value="" />
	<input type="hidden" name="currency_id" value="" />
	<input value="" name="product-private-data" type="hidden" id="pap_dx8vc2s5">
	<div class="ProductDetailsGrid ProductAddToCart">
		%%SNIPPET_ProductFieldsList%%
		<div class="ProductOptionList">
			%%SNIPPET_VariationList%%
		</div>
		%%SNIPPET_EventDate%%
		<div class="DetailRow" style="display: %%GLOBAL_DisplayAdd%%">
			<div class="Label QuantityInput" style="display: %%GLOBAL_DisplayAddQty%%">%%LNG_QuantityFull%%:</div>
			<div class="Value AddCartButton">
				<span class="FloatLeft" style="display: %%GLOBAL_DisplayAddQty%%;">
					%%GLOBAL_AddToCartQty%%
				</span>
				<div class="BulkDiscount">
					%%GLOBAL_AddToCartButtonOptimizerScriptTag%%
						<input type="image" src="%%GLOBAL_IMG_PATH%%/%%GLOBAL_SiteColor%%/AddCartButton.gif" alt="" />
					%%GLOBAL_AddToCartButtonOptimizerNoScriptTag%%
					<div class="BulkDiscountLink" style="display: %%GLOBAL_HideBulkDiscountLink%%;">
						<a href="#" onclick="$.iModal({data: $('#ProductDetailsBulkDiscountThickBox').html(), width: 600}); return false;">
							%%LNG_BulkDiscountLink%%
						</a>
					</div>
				</div>
			</div>
		</div>
	</div>
</form>

<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/notifysale.php" type="text/javascript">
</script>

<div class="OutOfStockMessage">
	%%SNIPPET_SideAddItemSoldOut%%
</div>

%%GLOBAL_ProductBulkDiscountThickBox%%

<script type="text/javascript">
lang.OptionMessage = "%%GLOBAL_OptionMessage%%";
lang.VariationSoldOutMessage = "%%LNG_VariationSoldOutMessage%%";
lang.InvalidQuantity = "%%LNG_InvalidQuantity%%";
lang.EnterRequiredField = "%%LNG_EnterRequiredField%%";
lang.InvalidFileTypeJS = "%%LNG_InvalidFileTypeJS%%";
var ShowAddToCartQtyBox = "%%GLOBAL_ShowAddToCartQtyBox%%";
</script>
%%GLOBAL_EventDateJavascript%%

3.

Edit all template files where is used add to cart link. Add attribute id="affCookieLinkId" into tag <a> in <div class="ProductActionAdd">

And into click tracking code add (after line PostAffTracker.track()):
PostAffTracker.writeCookieToLink('affCookieLinkId', 'product-private-data');

Code below shows tag <div class="ProductActionAdd"> after changes:

<div class="ProductActionAdd" style="display:%%GLOBAL_HideActionAdd%%;">
		<a href="%%GLOBAL_ProductURL%%" id="affCookieLinkId">%%GLOBAL_ProductAddText%%</a>
</div>

List of files, which you need to edit in directory /templates/__master/Snippets/

BrandProductsItem.html
CategoryProductsItem.html
HomeFeaturedProductsItem.html
HomeNewProductsItem.html
HomeSaleProductsItem.html
ProductVendorsOtherProductsItem.html
SearchResultProductGrid.html
SideCategoryNewProducts.html
SideCategoryPopularProducts.html
SideCategoryTopSellers.html
SideNewProducts.html
SideRecentlyViewedProducts.html
SideTopSellers.html
SideTopSellersFirst.html
TagProductsItem.html
VendorFeaturedItemsItem.html
VendorProductsItem.html

4.

Edit file class.cart.api.php

Edit file /includes/classes/class.cart.api.php

Find line public function AddItem( line number 1164 and add in the end of parameters new parameter $productPrivateData=null

It will look like:
public function AddItem($productId, $quantity=1, $variationDetails=null, $configurableOptions=array(), $cartItemId=null, $options=array(), $parentId=null, $reorder=false, $productPrivateData=null)

Next find cartProduct array (line 1319):
        $cartProduct = array(
            'product_id' => $productId,
            'variation_id' => $variation,
            'options' => $variationOptions,
            'quantity' => $quantity,
            'product_name' => $product['prodname'],
            'product_code' => $productCode,
            'product_price' => $productPrice,
            'original_price' => $originalPrice,
            'default_currency' => $defaultCurrency['currencyid'],
            'customer_group' => $customerGroup,
        );

add there 'product_private_data' => $productPrivateData

it will look like:
        $cartProduct = array(
            'product_id' => $productId,
            'variation_id' => $variation,
            'options' => $variationOptions,
            'quantity' => $quantity,
            'product_name' => $product['prodname'],
            'product_code' => $productCode,
            'product_price' => $productPrice,
            'original_price' => $originalPrice,
            'default_currency' => $defaultCurrency['currencyid'],
            'customer_group' => $customerGroup,
            'product_private_data' => $productPrivateData
        );

5.

Edit file class.cart.php

Edit file /includes/classes/class.cart.php

Find line:
$cartItemId = $this->api->AddItem($product_id, $qty, $variation, $configurableFields, null, $options, null, false);

change it like:
$cartItemId = $this->api->AddItem($product_id, $qty, $variation, $configurableFields, null, $options, null, false, $productPrivateData);

And add this before it:
            $productPrivateData = '';
            if(isset($_REQUEST['product-private-data'])) {
                $productPrivateData = $_REQUEST['product-private-data'];
            }

It will look after changes:

                        ...
                        ...
				$options['EventName'] = $eventName;
			}
			
			$productPrivateData = '';
			if(isset($_REQUEST['product-private-data'])) {
				$productPrivateData = $_REQUEST['product-private-data'];
			}

			// Actually add the product to the cart
			$cartItemId = $this->api->AddItem($product_id, $qty, $variation, $configurableFields, null, $options, null, false, $productPrivateData);
			$this->newCartItem = $cartItemId;

			if($cartItemId === false) {
                        ...
                        ...

6.

Add sale tracking code into file class.handler.php in googlecheckout method

Edit file /modules/checkout/googlecheckout/class.handler.php

Find this code around line 925:

		if (!$completed) {
			$GLOBALS['ISC_CLASS_LOG']->LogSystemError($this->logtype, sprintf(GetLang('GoogleCheckoutCantCompleteOrder'), isc_html_escape($pendingToken), isc_html_escape(var_export($completed, true))));
			return;
		}

add next code right below:

		include 'PapApi.class.php';
		$saleTracker = new Pap_Api_SaleTracker('URL_TO_PostAffiliatePro/scripts/sale.php');
		$prod_count = '1'; // Product Counter

		foreach($cartContent[$vendorId][0] as $cartItemId => $product) {
		    $productid = $product['data']['productid'];
		    $productPrivateData = $product['product_private_data'];
    
		    $price = $product['quantity'] * $product['product_price'];
    
		    if (strlen($productPrivateData) == 40) {  
			  $accountId = substr($productPrivateData, 0, 8);  
			  $visitorId = substr($productPrivateData, 8, 32);
		    } else {  
			  $visitorId = $productPrivateData;
			  $accountId = 'default1';
		    }
    
		    $saleTracker->setAccountId($accountId);
		    $saleTracker->setCookieValue($visitorId);
    
		    $sale = $saleTracker->createSale();
		    $sale->setTotalCost($price);
		    $sale->setOrderID($order['orderid'] . "($prod_count)");
		    $sale->setProductID($productid);  
		    $saleTracker->register();
		    $prod_count++;
		}

This tracking method is using PAP API. Therefore you need to have your actual PapApi.class.php file in directory /modules/checkout/googlecheckout/
(You can download it from your merchant panel > start > tools > integration > api integration > Download PAP API).