Twitch CASL - This is the first step towards compliance for the new CASL anti spam law in Canada. (Takes effect July 1st, 2014)
Tested and working with Zen 1.39h and 1.51.
Add to Database:
Table - cust_casl
Columns - cust_casl_id, date_checked, casl_purpose, ip_address
When a customer creates a new account...
Add to includes/modules/YOUR_TEMPLATE/create_account.php
PHP Code:
// bof Twitch CASL only record if they checked the box
if ($newsletter == '1') {
$sql = "insert into " . TABLE_CUST_CASL . "
(cust_casl_id, date_checked, casl_purpose, ip_address)
values ('" . (int)$_SESSION['customer_id'] . "', now(), 'Yes, I would like to receive emails from YOUR_COMPANY_HERE regarding upcoming promotions', '". $_SERVER['REMOTE_ADDR'] . "')";
$db->Execute($sql);
}
// eof Twitch CASL
(replace YOUR_COMPANY_HERE with your company name)
When a customer changes their newsletter settings via account_edit...
Add to includes/modules/pages/account_newsletters/header_php.php
PHP Code:
// bof Twitch CASL only record if they checked the box
//
// load cust_id from casl if exists
$casl_query = "SELECT cust_casl_id
FROM " . TABLE_CUST_CASL . "
WHERE cust_casl_id = '" . (int)$_SESSION['customer_id'] . "' ";
$casl_check = $db->Execute($casl_query);
if ($casl_check == '') { // no record found for this customer
if ($newsletter_general == '1') { // add the casl record ONLY if they checked the box
$sql = "insert into " . TABLE_CUST_CASL . "
(cust_casl_id, date_checked, casl_purpose, ip_address)
values ('" . (int)$_SESSION['customer_id'] . "', now(), 'Yes, I would like to receive emails from YOUR_COMPANY_HERE regarding upcoming promotions', '". $_SERVER['REMOTE_ADDR'] . "')";
$db->Execute($sql);
} // end checked box - insert new
} else { // if casl customer record already exists, update the date_checked and ip_address ONLY if the box is checked
if ($newsletter_general == '1') { // add the casl record ONLY if they checked the box
$sql = "update " . TABLE_CUST_CASL . "
set date_checked = now(), ip_address = '". $_SERVER['REMOTE_ADDR'] . "'
where cust_casl_id = '" . (int)$_SESSION['customer_id'] . "' ";
$db->Execute($sql);
} // end checked box update
} // end CASL check
//
// eof Twitch CASL only record if they checked the box
(replace YOUR_COMPANY_HERE with your company name)
Bookmarks