Here's the code that I ended up using. Maybe no one wants to open the file. This is the tail end that does the query and send the call to our idev. This works but you can see up above it's still not quite right. Any input on the matter would be greatly appreciated.
PHP Code:
<?PHP }
if ((int)$orders_id > 0) {
$IDEV = $db->Execute("select class, value from " . TABLE_ORDERS_TOTAL . " where orders_id = '".(int)$orders_id."' AND class in ('ot_coupon', 'ot_subtotal', 'ot_group_pricing')");
while (!$IDEV->EOF) {
switch ($IDEV->fields['class']) {
case 'ot_subtotal':
$order_subtotal = $IDEV->fields['value'];
break;
case 'ot_coupon':
$coupon_amount = $IDEV->fields['value'];
break;
case 'ot_group_pricing':
$group_pricing_amount = $IDEV->fields['value'];
break;
}
$IDEV->MoveNext();
}
if (!isset($order_summary['products_ordered_models'])) {
$products_array = array();
$products_query = "SELECT products_id, products_model
FROM " . TABLE_ORDERS_PRODUCTS . "
WHERE orders_id = :ordersID
ORDER BY products_id";
$products_query = $db->bindVars($products_query, ':ordersID', $orders_id, 'integer');
$products = $db->Execute($products_query);
while (!$products->EOF) {
$products_array[urlencode($products->fields['products_id'])] = urlencode($products->fields['products_model']);
$products->MoveNext();
}
$idev_sale_amount = ($order_subtotal - $coupon_amount - $group_pricing_amount);
$idev_sale_amount = number_format($idev_sale_amount,2,'.','');
$idev_coupon_code = mysql_query("select coupon_code from " . TABLE_ORDERS . " where orders_id = '" . (int)$orders_id . "'");
$idev_coupon_code = mysql_fetch_array($idev_coupon_code);
$idev_coupon_code = $idev_coupon_code['coupon_code'];
$order_summary['products_ordered_ids'] = implode('|', array_keys($products_array));
$order_summary['products_ordered_models'] = implode('|', array_values($products_array));
}
echo '<script type="text/javascript" src="https://www.mysite.com/idevaffiliate/sale.php?profile=1&idev_saleamt=' . $order_summary['commissionable_order_formatted'] .
'&idev_ordernum=' . $order_summary['order_number'] . '&products_purchased=' . $order_summary['products_ordered_models'] . '&coupon_code=' . urlencode($order_summary['coupon_code']) .
'"></script>';
echo "</td></tr></table>";
}
?>