Zen Cart Logo
Forums / All Other Contributions/Addons / Help with custom code on checkout success page (iDevAffiliate)

Help with custom code on checkout success page (iDevAffiliate)

Views: 3,308

Results 1 to 14 of 14
20 Jul 2012, 1:55 PM
#1
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Help with custom code on checkout success page (iDevAffiliate)

I am trying to install iDevAffiliate on my shop. The program itself seems to work correctly, but when I install the tracking code on the checkout success header, it makes the font on my checkout success page HUGE. I have no idea why it would do this. I'm wondering if there are any php gurus out there that can take a look at the code and see if there is something that might be wrong?

These are their instructions:

Edit this file: /zencart/includes/modules/pages/checkout_success/header_php.php.

Find the following code which already exists in the file.

$zv_orders_id = $orders->fields['orders_id'];

That code actually doesn't exist in my header file... So I added their code beneath "$orders_id = $zv_orders_id;"

This is the code they provide to insert:

$idev = $db->Execute("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '".(int)$orders->fields['orders_id']."' AND class = 'ot_subtotal'");
$idev_saleamt = (number_format($idev->fields['value'],2));
$idev_ordernum = $idev->fields['orders_id'];
print "<script language=\"JavaScript\" type=\"text/javascript\" src=\"http://www.saffireblue.ca/idevaffiliate/sale.php?profile=13&idev_saleamt=$idev_saleamt&idev_ordernum=$idev_ordernum\"></script>";

I can't figure out why it would ignore my css font size and make the font so huge...?

I tried adding #checkoutsuccessBody to my checkout_success.css, but it seems to ignore that too. Anyone have any ideas?

Thanks in advance.

20 Jul 2012, 3:33 PM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Help with custom code on checkout success page (iDevAffiliate)

We need to see the site live to diagnose styling issues. If the problem only happens on the checkout_success page, we would need to complete a transaction. Do you have check/money order enabled so we could do a test "purchase" without actually paying?

Also, if they say that a certain bit of code exists in a file and it doesn't, you should ask them for clarification. This one doesn't seem like it ought to matter for placement, but you never know.

20 Jul 2012, 3:39 PM
#3
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Re: Help with custom code on checkout success page (iDevAffiliate)

I did submit a ticket with iDev, but they aren't open for another 1/2 hour and their estimated wait time is 8 hours. So hopefully they'll respond to me as well.

Here's a link to my site. The only problem is that I can't leave the iDev code installed unless I know when you are going to be testing. I can't leave it live for customers to see the screwy success page... LOL

20 Jul 2012, 3:52 PM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Help with custom code on checkout success page (iDevAffiliate)

Do you have the affiliate code active now? I just "ordered" a book and don't see anything out of the ordinary, except that there is a bit of stray HTML at the bottom of the page:

Please direct any questions you have to customer service.
Thanks for shopping with us online!
" width="1" height="1">

20 Jul 2012, 3:56 PM
#5
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Re: Help with custom code on checkout success page (iDevAffiliate)

No, I don't have it active now. I had inserted their generic pixel tracking code on that page instead, but obviously screwed it up, since it was leaving that width/height hanging. LOL

I will add the code now if you can test within the next few minutes...

20 Jul 2012, 3:59 PM
#6
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Re: Help with custom code on checkout success page (iDevAffiliate)

Ok, give it a try now....

20 Jul 2012, 3:59 PM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Help with custom code on checkout success page (iDevAffiliate)

View source for the page shows this ```

<h3 id="checkoutSuccessThanks" class="centeredContent">Thanks for shopping with us online!</h3>

<img border="0" src="http://www.saffireblue.ca/idevaffiliate/sale.php?profile=72198&idev_saleamt=15.95&idev_ordernum=11195">" width="1" height="1">

<!-- Google Code for Order Submit Conversion Page -->

What browser are you using? Firefox handles this HTML error by just showing the leftover as text, but all browsers handle errors differently.
20 Jul 2012, 4:02 PM
#8
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Re: Help with custom code on checkout success page (iDevAffiliate)

Yes, I just removed that code. Can you try reloading the success page now?

20 Jul 2012, 4:05 PM
#9
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Re: Help with custom code on checkout success page (iDevAffiliate)

So I'm looking at the source, and it seems to put the iDev javascript before the opening <html> code...

<script language="JavaScript" type="text/javascript" src="https://www.xxxxx.com/idevaffiliate/sale.php?profile=13&idev_saleamt=3.60&idev_ordernum=9503"></script><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head>

Hmmmm. That must be what's causing the page to be screwy... but how to fix it, I dunno. LOL

20 Jul 2012, 4:12 PM
#10
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Re: Help with custom code on checkout success page (iDevAffiliate)

I just removed the code, so it will look normal now. But here's what my header file looked like....

<?php
/**
 * checkout_success header_php.php
 *
 * @package page
 * @copyright Copyright 2003-2010 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: header_php.php 16909 2010-07-15 20:02:37Z drbyte $
 */

// This should be first line of the script:
$zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_SUCCESS');

// if the customer is not logged on, redirect them to the shopping cart page
if (!$_SESSION['customer_id']) {
  zen_redirect(zen_href_link(FILENAME_TIME_OUT));
}

if (!isset($_GET['action']) || (isset($_GET['action']) && $_GET['action'] != 'confirm')) {

$notify_string='';
if (isset($_GET['action']) && ($_GET['action'] == 'update')) {
  $notify_string = 'action=notify&';
  $notify = $_POST['notify'];

  if (is_array($notify)) {
    for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
      $notify_string .= 'notify[]=' . $notify[$i] . '&';
    }
    if (strlen($notify_string) > 0) $notify_string = substr($notify_string, 0, -1);
  }
  if ($notify_string == 'action=notify&') {
      zen_redirect(zen_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));
  } else {
    zen_redirect(zen_href_link(FILENAME_DEFAULT, $notify_string));
  }
}

require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
$breadcrumb->add(NAVBAR_TITLE_1);
$breadcrumb->add(NAVBAR_TITLE_2);

// find out the last order number generated for this customer account
$orders_query = "SELECT * FROM " . TABLE_ORDERS . "
                 WHERE customers_id = :customersID
                 ORDER BY date_purchased DESC LIMIT 1";
$orders_query = $db->bindVars($orders_query, ':customersID', $_SESSION['customer_id'], 'integer');
$orders = $db->Execute($orders_query);
$orders_id = $orders->fields['orders_id'];


// use order-id generated by the actual order process
// this uses the SESSION orders_id, or if doesn't exist, grabs most recent order # for this cust (needed for paypal et al).
// Needs reworking in v1.4 for checkout-rewrite
$zv_orders_id = (isset($_SESSION['order_number_created']) && $_SESSION['order_number_created'] >= 1) ? $_SESSION['order_number_created'] : $orders_id;
$orders_id = $zv_orders_id;

//BEGIN IDEV CODE
$idev = $db->Execute("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '".(int)$orders->fields['orders_id']."' AND class = 'ot_subtotal'");
$idev_saleamt = (number_format($idev->fields['value'],2));
$idev_ordernum = $idev->fields['orders_id'];
print "<script language=\"JavaScript\" type=\"text/javascript\" src=\"https://www.XXXX.com/idevaffiliate/sale.php?profile=13&idev_saleamt=$idev_saleamt&idev_ordernum=$idev_ordernum\"></script>";
//END IDEV CODE

$order_summary = $_SESSION['order_summary'];
unset($_SESSION['order_summary']);
unset($_SESSION['order_number_created']);



// prepare list of product-notifications for this customer
$global_query = "SELECT global_product_notifications
                 FROM " . TABLE_CUSTOMERS_INFO . "
                 WHERE customers_info_id = :customersID";

$global_query = $db->bindVars($global_query, ':customersID', $_SESSION['customer_id'], 'integer');
$global = $db->Execute($global_query);
$flag_global_notifications = $global->fields['global_product_notifications'];

if ($flag_global_notifications != '1') {

  $products_array = array();
  $counter = 0;

  $products_query = "SELECT products_id, products_name
                     FROM " . TABLE_ORDERS_PRODUCTS . "
                     WHERE orders_id = :ordersID
                     ORDER BY products_name";

  $products_query = $db->bindVars($products_query, ':ordersID', $orders_id, 'integer');
  $products = $db->Execute($products_query);

  while (!$products->EOF) {
    $notificationsArray[] = array('counter'=>$counter,
                                  'products_id'=>$products->fields['products_id'],
                                  'products_name'=>$products->fields['products_name']);
    $counter++;
    $products->MoveNext();
  }
}

  $flag_show_products_notification = (CUSTOMERS_PRODUCTS_NOTIFICATION_STATUS == '1' and sizeof($notificationsArray)>0 and $flag_global_notifications != '1') ? true : false ;

  $products_displayed = array();


  $gv_query = "SELECT amount
               FROM " . TABLE_COUPON_GV_CUSTOMER . "
               WHERE customer_id = :customersID ";

  $gv_query = $db->bindVars($gv_query, ':customersID', $_SESSION['customer_id'], 'integer');
  $gv_result = $db->Execute($gv_query);

  if ($gv_result->fields['amount'] > 0 ) {
    $customer_has_gv_balance = true;
    $customer_gv_balance = $currencies->format($gv_result->fields['amount']);
  }


// include template specific file name defines
$define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_CHECKOUT_SUCCESS, 'false');

} else {
  echo '<html><head>';
  echo '<script type="text/javascript">
<!--
theTimer = 0;
timeOut = 12;

function submit_form()
{
  theTimer = setTimeout("submit_form();", 100);
  if (timeOut > 0) {
    timeOut -= 1;
  }
  else
  {
    clearTimeout(theTimer);
    document.getElementById("submitbutton").disabled = true;
    document.forms.formpost.submit();
  }
}
function continueClick()
{
  clearTimeout(theTimer);
  return true;
}

submit_form();
//-->
</script>' . "\n" . '</head>';
  echo '<body style="text-align: center; min-width: 600px;">' . "\n" . '<div style="text-align: center;  width: 600px;  margin-left: auto;  margin-right: auto; margin-top:20%;"><p>This page will automatically redirect you back to ' . STORE_NAME . ' for your order confirmation details.<br />If you are not redirected within 5 seconds, please click the button below to continue.</p>';
  echo "\n" . '<form action="' . zen_href_link(FILENAME_CHECKOUT_SUCCESS, zen_get_all_get_params(array('action')), 'SSL', false) . '" method="post" name="formpost" />' . "\n";
  reset($_POST);
  while (list($key, $value) = each($_POST)) {
    if (!is_array($_POST[$key])) {
      echo zen_draw_hidden_field($key, htmlspecialchars(stripslashes($value))) . "\n";
    }
  }
  echo "\n" . '<input type="submit" class="submitbutton" id="submitbutton" value=" Continue " onclick="continueClick()" />' . "\n";
  echo '</form></div></body></html>';
  exit();
}

// This should be last line of the script:
$zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_SUCCESS');
20 Jul 2012, 4:37 PM
#11
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Re: Help with custom code on checkout success page (iDevAffiliate)

So I figured out if I take the javascript bit of code and put it in the javascript file instead of the header file, it shows up in the right place, but I'm not sure how I can make the variables pass over to the javascript file?

<script language="javascript" type="text/javascript" src="https://www.XXXX.com/idevaffiliate/sale.php?profile=13&idev_saleamt=$idev_saleamt&idev_ordernum=$idev_ordernum"></script>

Ah well, I will just use the generic pixel tracking for now and wait for iDev's response, unless you have any suggestions? :)

Thanks for your help.

20 Jul 2012, 4:42 PM
#12
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Help with custom code on checkout success page (iDevAffiliate)

Okay, I placed another order and see the font size issue. You can turn it off now.
There are a couple of things that are wrong or odd. The usual font-size resetting to 62.5% is overridden, but no overriding declaration shows up in Firebug. Thus it is using the base browser font-size setting (100%). The difficulty here is that I can't see what is causing the override.

I get a CSS error message in the validator icon: Unknown pseudo-class or pseudo-element "a". Ruleset ignored due to bad selector. It then points to your stylesheet.css, line 16.
Your stylesheet has this

.myButton
a{color:#fff}.myButton:a:visited{color:#fff}.myButton:hover{background-color:#a81c72;color:#fff}.myButton:active{position:relative;top:1px;color:#fff}
``` which ought to be
.myButton a:visited{color:#fff}
This doesn't seem like it should be related to the problem.

There is another CSS error: An unbalanced tree was written using document.write() ... and refers to "line 25".
This indicates a javascript error, which I can't help find or fix. The likely source would be the affiliate javascript. 
Line 25 in your page's view source is

<script type="text/javascript" src="min/?f=/shop/includes/templates/saffire2/jscript/jscript_imagehover.js&1327610682"></script>

which wouldn't apply here and not on other pages.
20 Jul 2012, 4:55 PM
#13
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Help with custom code on checkout success page (iDevAffiliate)

  1. Your "large font" is a result of your code changes outputting HTML in the wrong order, thus breaking the page layout and the browser getting confused.

  2. The code you've been given (as quoted in your first post) is outdated. Neither of the code changes you posted is needed. Remove them and do the following instead:

Create a new file: /includes/modules/pages/checkout_success/jscript_idevaffiliate.php```

<?php $idev_saleamt = number_format($order_summary['commissionable_order'], 2); $idev_ordernum = $order_summary['order_number']; echo "<script language=\"javascript\" type=\"text/javascript\" src=\"http://www.saffireblue.ca/idevaffiliate/sale.php?profile=13&idev_saleamt=$idev_saleamt&idev_ordernum=$idev_ordernum\"></script>"; ``` Ref: <http://www.zen-cart.com/content.php?322-Integrating-Sales-Analytics-and-Affiliates-Tools>
20 Jul 2012, 5:03 PM
#14
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Re: Help with custom code on checkout success page (iDevAffiliate)

THANK YOU SO MUCH, DrByte!