Skip to content

Instantly share code, notes, and snippets.

@drbyte
Created December 11, 2023 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drbyte/d503661e2b91353e82f8790a2e982cfb to your computer and use it in GitHub Desktop.
Save drbyte/d503661e2b91353e82f8790a2e982cfb to your computer and use it in GitHub Desktop.
Coupon/ReferralCode Tracking / auto-apply in Zen Cart
<?php
$autoLoadConfig[100][] = array('autoType'=>'init_script',
'loadFile'=> 'init_referral_tracking.php');
<?php
/**
* initialize referral-tracking-system variables
*
* Determines which referral code the customer came in on
*
*/
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
// REFERRALS SYSTEM (c/f modules/checkout_process.php and tpl_checkout_success_default.php)
if (isset($_GET['ref']) && $_GET['ref'] != '') {
$_SESSION['referral_code'] = $_GET['ref'];
if ($_GET['ref'] == 'vt') {
$_SESSION['referral_code'] = 'vtarget';
$_SESSION['cc_id']='vtarget';
}
}
// TESTING - the following dumps the referral-code for this session into the page-headers as a comment, which is invisible to customers. It only shows up for administrators' PC's whose IP address is in the down-for-maint list.
if (strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])) {
if (isset($_SESSION['referral_code'])) $debug_message .= '<!-- ref=' . $_SESSION['referral_code'] . ' -->';
// print_r($_COOKIE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment