Page 1 of 3 123 LastLast
Results 1 to 10 of 24
  1. #1
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,480
    Plugin Contributions
    18

    Default July 2014 Canada Anti-Spam Legislation (CASL) Twitch CASL

    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

    Name:  twitch_cust_casl_table.JPG
Views: 385
Size:  36.7 KB

    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)
    Twitch.
    http://www.twitchtoo.com - Do you work for free? Please donate.
    Twitch Wholesale + Attributes, ZC 1.38 - 1.56c - Expert Site Migration & Upgrades!

  2. #2
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,480
    Plugin Contributions
    18

    Default Re: NEW - Government of Canada Anti-Spam Legislation (CASL) Twitch CASL

    Understanding how this code works:

    New Customer
    - When a new customer signs up and does not click the newsletter checkbox, nothing happens. When they check the box the customer_id, date and time, static text displayed that they are agreeing to, ip address are recorded in the CUST_CASL table.

    Existing Customer - When an existing customer logs into their account, goes to 'My Account' and selects 'Subscribe or unsubscribe from newsletter' they land on a page with a checkbox showing their previous newsletter setting.

    Scenario A - The newsletter box was never checked
    -> All of the required fields will be added to the CUST_CASL table if they check the box.

    Scenario B - The newsletter box was previously checked - remains checked - and they click update
    -> The current date and time, current ip address will be updated in the existing customer field.

    Note: If they previously did check the newsletter box, then they uncheck the box, the CASL records will remain intact. This ensures that any customer complaints can be traced back to a date, time and ip address for legal means.


    As always, backup your site before making changes, read and follow the regulations provided by the Government of Canada related to CASL compliance for your own business, donations are appreciated :)
    Twitch.
    http://www.twitchtoo.com - Do you work for free? Please donate.
    Twitch Wholesale + Attributes, ZC 1.38 - 1.56c - Expert Site Migration & Upgrades!

  3. #3
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,480
    Plugin Contributions
    18

    Default Re: 2014 Government of Canada Anti-Spam Legislation (CASL) Twitch CASL

    To display the database records for those that have checked the newsletter box located at:

    Admin -> Customers -> Select Customer -> Click Edit

    In 'Options - Send me Discounts and Deals through email.' below the newsletter dropdown in admin/customers.php

    Look for:
    PHP Code:
                <td class="main"><?php echo ENTRY_NEWSLETTER?></td>
                <td class="main">
    <?php
      
    if ($processed == true) {
        if (
    $cInfo->customers_newsletter == '1') {
          echo 
    ENTRY_NEWSLETTER_YES;
        } else {
          echo 
    ENTRY_NEWSLETTER_NO;
        }
        echo 
    zen_draw_hidden_field('customers_newsletter');
      } else {
        echo 
    zen_draw_pull_down_menu('customers_newsletter'$newsletter_array, (($cInfo->customers_newsletter == '1') ? '1' '0'));
      }

    ?></td>
    Add this code after the trailing </td>:
    PHP Code:
    <?php // bof Twitch CASL ?>
    <tr> <td>&nbsp;</td> 
    <td> 
    <?php 
    // Display db records in admin
        
    $casl_query "SELECT *
                       FROM   " 
    TABLE_CUST_CASL "
                       WHERE  cust_casl_id = '" 
    . (int)$customers_id "' ";
        
    $casl_check $db->Execute($casl_query);

         if (
    $casl_check->fields['cust_casl_id'] == (int)$customers_id  ) {
        
    // output the db record
            
    echo '<strong>Customer ID: </strong>' $casl_check->fields['cust_casl_id'] . '&nbsp;' ;
            echo 
    '<strong>Date Last Checked: </strong>' $casl_check->fields['date_checked'] . '&nbsp;' ;
            echo 
    '<strong>Agreement: </strong>' $casl_check->fields['casl_purpose'] . '&nbsp;' ;
            echo 
    '<strong>Location: </strong>' $casl_check->fields['ip_address'] . '&nbsp;' ;

         } else { 
        
    // No record found meaning the customer has not checked the newsletter box
            
    echo 'No CASL record found. Customer has not checked newsletter subscribe box.';

        }
    ?>
    </td>
    <td>&nbsp;</td>
    </tr>
    <?php // eof Twitch CASL ?>
    Twitch.
    http://www.twitchtoo.com - Do you work for free? Please donate.
    Twitch Wholesale + Attributes, ZC 1.38 - 1.56c - Expert Site Migration & Upgrades!

  4. #4
    Join Date
    Nov 2007
    Posts
    11
    Plugin Contributions
    0

    Default Re: 2014 Government of Canada Anti-Spam Legislation (CASL) Twitch CASL

    Hi, I tried to do all of these steps for 1.51 and it's not working. After I made the DB changes by adding a new table with the 4 columns, I added the code lines in those files. The result is that I've got an error message every time when I make (confirm) a new account and also when I try to update the mail newsletter settings for an existing account. Can you be more specific where in those two files (create_account.php and header_php.php) should I add the code lines? Please help, first of July is coming.

  5. #5
    Join Date
    Nov 2007
    Posts
    11
    Plugin Contributions
    0

    Default Re: 2014 Government of Canada Anti-Spam Legislation (CASL) Twitch CASL

    Is there other place where I need to modify the code or there are some hidden settings to do before?
    Last edited by verzea; 19 Jun 2014 at 10:54 PM.

  6. #6
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,480
    Plugin Contributions
    18

    Default Re: 2014 Government of Canada Anti-Spam Legislation (CASL) Twitch CASL

    Quote Originally Posted by verzea View Post
    Hi, I tried to do all of these steps for 1.51 and it's not working. After I made the DB changes by adding a new table with the 4 columns, I added the code lines in those files. The result is that I've got an error message every time when I make (confirm) a new account and also when I try to update the mail newsletter settings for an existing account. Can you be more specific where in those two files (create_account.php and header_php.php) should I add the code lines? Please help, first of July is coming.
    In includes/modules/YOUR_TEMPLATE/create_account.php after the following code:

    PHP Code:
        $sql "insert into " TABLE_CUSTOMERS_INFO "
                              (customers_info_id, customers_info_number_of_logons,
                               customers_info_date_account_created, customers_info_date_of_last_logon)
                  values ('" 
    . (int)$_SESSION['customer_id'] . "', '1', now(), now())";

        
    $db->Execute($sql); 
    (around line 319) you can add the Twitch CASL code.

    In includes/modules/pages/account_newsletters/header_php.php after the following code:

    PHP Code:
        $sql "UPDATE " TABLE_CUSTOMERS "
                SET    customers_newsletter = :customersNewsletter
                WHERE  customers_id = :customersID"
    ;

        
    $sql $db->bindVars($sql':customersID',$_SESSION['customer_id'], 'integer');
        
    $sql $db->bindVars($sql':customersNewsletter',$newsletter_general'integer');
        
    $db->Execute($sql);
      } 
    (around line 43) you can add the Twitch CASL code.
    Twitch.
    http://www.twitchtoo.com - Do you work for free? Please donate.
    Twitch Wholesale + Attributes, ZC 1.38 - 1.56c - Expert Site Migration & Upgrades!

  7. #7
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,480
    Plugin Contributions
    18

    Default Re: 2014 Government of Canada Anti-Spam Legislation (CASL) Twitch CASL

    Quote Originally Posted by verzea View Post
    Is there other place where I need to modify the code or there are some hidden settings to do before?
    There are no hidden settings. The database tables must be set exactly as listed in the original post #1. Next the Twitch CASL code needs to be cut and paste into the various php files in the locations posted in post #3 and #6.

    If you are still having errors, it's best to contact me directly via email, or to this thread - with a copy of the error message or the most recent error listed in your /logs folder.

    Or if you'd like I can check it for you, make email contact with me first then we'll share usernames and passwords for admin/FTP.
    Twitch.
    http://www.twitchtoo.com - Do you work for free? Please donate.
    Twitch Wholesale + Attributes, ZC 1.38 - 1.56c - Expert Site Migration & Upgrades!

  8. #8
    Join Date
    Nov 2007
    Posts
    11
    Plugin Contributions
    0

    Default Re: 2014 Government of Canada Anti-Spam Legislation (CASL) Twitch CASL

    The message is: WARNING: An Error occurred, please refresh the page and try again.

    -the DB table looks identical
    -the code is placed on the right place
    -when I create a new account as a Canadian, once I checked the Newsletter and hit created I received this error
    -if I log in with a different account (Canadian as well) and check My Account / Newsletter Subscription (which is already "on") and hit Update button, again, the error message

    Thanks in advance :)

    (it looks that nothing is written on the DB for the table zen_cust_casl)

  9. #9
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,480
    Plugin Contributions
    18

    Default Re: 2014 Government of Canada Anti-Spam Legislation (CASL) Twitch CASL

    Quote Originally Posted by verzea View Post
    The message is: WARNING: An Error occurred, please refresh the page and try again.

    -the DB table looks identical
    -the code is placed on the right place
    -when I create a new account as a Canadian, once I checked the Newsletter and hit created I received this error
    -if I log in with a different account (Canadian as well) and check My Account / Newsletter Subscription (which is already "on") and hit Update button, again, the error message

    Thanks in advance :)

    (it looks that nothing is written on the DB for the table zen_cust_casl)
    Check your PM, I need access to trace this problem.
    Twitch.
    http://www.twitchtoo.com - Do you work for free? Please donate.
    Twitch Wholesale + Attributes, ZC 1.38 - 1.56c - Expert Site Migration & Upgrades!

  10. #10
    Join Date
    Sep 2006
    Location
    New Brunswick, Canada
    Posts
    10
    Plugin Contributions
    0

    Default Re: 2014 Government of Canada Anti-Spam Legislation (CASL) Twitch CASL

    verzea,

    Did you define the new table in database_tables.php?
    If not, add the following line at the end of file:

    define('TABLE_CUST_CASL', DB_PREFIX . 'cust_casl');

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v151 UK New Distance Selling Legislation June 2014
    By adb34 in forum General Questions
    Replies: 26
    Last Post: 12 Aug 2014, 06:50 PM
  2. v151 enactment of the Canadian Anti-Spam Law (CASL)?
    By muah in forum General Questions
    Replies: 4
    Last Post: 30 Jul 2014, 02:18 AM
  3. v151 Terms and Conditions checkbox on contact us page (anti-spam)
    By Axeman in forum General Questions
    Replies: 6
    Last Post: 15 May 2014, 02:55 AM
  4. Google css anti-spam on Tell a Friend
    By ricangem in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 17 Sep 2011, 08:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR