Forums / All Other Contributions/Addons / Snap Affiliates v2.0 for v1.5.0 and later

Snap Affiliates v2.0 for v1.5.0 and later

Views: 68,399

Results 101 to 120 of 464
7 Aug 2013, 9:40 PM
#101
picandnix avatar

picandnix

Totally Zenned

Join Date:
Dec 2010
Location:
UK
Posts:
1,780
Plugin Contributions:
2

Snap Affiliates v2.0 for v1.5.0 and later

Loving the update Lat9 :hug:

15 Aug 2013, 11:43 AM
#102
picandnix avatar

picandnix

Totally Zenned

Join Date:
Dec 2010
Location:
UK
Posts:
1,780
Plugin Contributions:
2

Re: Snap Affiliates v2.0 for v1.5.0 and later

Just a thought to add to the 'wish'/update list;
Admin tracking of the banner images that are selected by affiliates, which banner is more popular/best return of sales.

Thanks :hug:

8 Sep 2013, 5:24 PM
#103
bugwater avatar

bugwater

New Zenner

Join Date:
Sep 2013
Posts:
9
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

Having an issue with secure site and images. For some reason the tools page with banners on it is throwing up an non-secure warning. I couldnt find where to change it in the files, but shouldnt it be setup with a relative link so it automatically changes to secure when pple login.

Right now its throwing people the warning message that there are non-secure items on the page.(from the banners)

Any work around for this?

Latest version downloaded yesterday, also running ultimate seo. Tried it with seo on and off, same result.

Everything else works great. Pretty easy to install also, once you get past all the edits for a shop with lots of customized files.

Thanks in advance
Bill H.
https://www.bug-water.com

8 Sep 2013, 6:12 PM
#104
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

@BugWater, I believe that this will fix the issue (I don't currently have an HTTPS test site with the plugin installed). Make the following modifications to the get_referrer_image function in /includes/templates/YOUR_TEMPLATE/tpl_referrer_tools_default.php (starts on line 23):

function get_referrer_image($width, $height, $filename) {
  global $request_type;  /*v2.5.1a*/
  $image_html = '';
  $alt = TEXT_IMAGE_ALT_TEXT;
  $filename = (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG . $filename;  /*v2.3.0a,v2.5.1c*/
  $image_html .= '<div class="imagewrap">';
  $image_html .= '<div class="imagetitle">' . sprintf(TEXT_X_BY_Y_PIXELS, $width, $height) . '</div>';
  $image_html .= "<img class=\"referrer_image\" src=\"$filename\" width=\"$width\" height=\"$height\" alt=\"$alt\" /><br />";
  $image_html .= '<textarea rows="3" cols="1"><a href="' . get_referrer_link(FILENAME_DEFAULT) . "\"><img src=\"$filename\" width=\"$width\" height=\"$height\" alt=\"$alt\" /></a></textarea><br />";
  $image_html .= '</div>';

  return $image_html;
}

Please let me know if this corrects the issue; I've got another correction in the queue ...

8 Sep 2013, 6:24 PM
#105
bugwater avatar

bugwater

New Zenner

Join Date:
Sep 2013
Posts:
9
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

It most certainly did, that was awesomely fast support.

Thanks

Sweet, im off to email my freak out pple that sweat the little things in life.
(fricken browser popups created for those that dont know better create more work then they are worth)

8 Sep 2013, 6:38 PM
#106
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

No problem; thanks for the bug report (and letting me know that the fix worked)!

8 Sep 2013, 7:13 PM
#107
bugwater avatar

bugwater

New Zenner

Join Date:
Sep 2013
Posts:
9
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

Now thats its all working smooth I got a few sites to add it too. So im just going to make both variations in the file and just comment out the one not needed.

Maybe i can just put it in an includes file, and add it into the folder structure. Then I can change it anytime needed. Hmmm.

Thanks Again

8 Sep 2013, 8:08 PM
#108
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

Here's the update I was alluding to for /includes/modules/pages/referrer_main/header_php.php. The issue was that if you have no orders-status exclusions that the referrers' activity details won't display:

<?php
// +----------------------------------------------------------------------+
// |Snap Affiliates for Zen Cart                                          |
// +----------------------------------------------------------------------+
// | Copyright (c) 2013, Vinos de Frutas Tropicales (lat9) for ZC 1.5.0+  |
// |                                                                      |
// | Original: Copyright (c) 2009 Michael Burke                           |
// | http://www.filterswept.com                                           |
// |                                                                      |
// | This source file is subject to version 2.0 of the GPL license.       |
// +----------------------------------------------------------------------+

require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));

$breadcrumb->add(NAVBAR_TITLE);

$today = getdate();

$referrer = null;
$submitted = false;
$approved = false;
$banned = false;
$is_referrer = false;
$is_logged_in = isset ($_SESSION['customer_id']);

$total_total = 0;
$total_commission = 0;
$unpaid_total = 0;
$unpaid_commission = 0;
$yearly_total = 0;
$yearly_commission = 0;
$last_payout = 0;
$next_payout = 0;

$activity_begin = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
$activity_end = mktime(23, 59, 59, $activity_begin['mon'] + 1, 0, $today['year']);
$activity_total = 0;
$activity_commission = 0;
$activity = array();

if (isset($_GET['start'])) {
  $activity_begin = intval ($_GET['start']);
}

if( $activity_begin > time() ) {
  $activity_begin = time();
}

if (isset ($_GET['end'])) {
  $activity_end = intval( $_GET['end'] );
}

if ($activity_begin > $activity_end) {
  $tempDate = getdate ($activity_begin);

  $activity_end = mktime (23, 59, 59, $tempDate['mon']+1, 0, $tempDate['year']);
}

if (!$is_logged_in) {
  zen_redirect(zen_href_link(FILENAME_REFERRER_SIGNUP, '', "SSL"));
  
} else {
  $query = "SELECT * FROM ". TABLE_REFERRERS ." WHERE referrer_customers_id = " . (int)$_SESSION['customer_id'];
  $referrer = $db->Execute($query);

  if (!is_object($referrer) || $referrer->EOF ) {
    zen_redirect(zen_href_link(FILENAME_REFERRER_SIGNUP, '', "SSL"));
    
  } else {
    $submitted = true;
    $approved = (bool)$referrer->fields['referrer_approved'];
    $banned = (bool)$referrer->fields['referrer_banned'];

    if ($approved) {
      if (!defined('SNAP_ORDER_STATUS_EXCLUSIONS')) define('SNAP_ORDER_STATUS_EXCLUSIONS', ''); /*v2.1.0a*/     
      if (!defined('SNAP_ORDER_TOTALS_EXCLUSIONS')) define('SNAP_ORDER_TOTALS_EXCLUSIONS', 'ot_tax,ot_shipping');

//-bof-v2.1.0c (changed $exclude_array to $totals_exclude_array
      $totals_exclude_array = explode(',', SNAP_ORDER_TOTALS_EXCLUSIONS);
      
      for ($i = 0, $totals_exclude_clause = '', $n = count($totals_exclude_array); $i < $n; $i++) {
        if ($i != 0) {
          $totals_exclude_clause .= ' OR ';
        }
        $totals_exclude_clause .= ("t.class = '" . $totals_exclude_array[$i] . "'");
      }
      if ($totals_exclude_clause != '') {
        $totals_exclude_clause = " AND ( $totals_exclude_clause ) ";
      }
//-eof-v2.1.0c

      $year_start = mktime(0,0,0, 1, 1, $today['year']);

//-bof-v2.1.0a: Don't show commission for orders status values in the "exclude list".
      $status_exclude_array = explode(',', SNAP_ORDER_STATUS_EXCLUSIONS);
//-eof-v2.1.0a

      $no_status_exclusions = (sizeof($status_exclude_array) == 1 && $status_exclude_array[0] == '') ? true : false;  /*v2.5.1a*/
      
      $query = "SELECT o.orders_id, o.date_purchased, o.order_total, c.commission_paid, c.commission_rate, o.orders_status
	                FROM ". TABLE_ORDERS ." o, " . TABLE_COMMISSION . " c 
                  WHERE c.commission_referrer_key = '" . $referrer->fields['referrer_key'] . "' 
                    AND o.orders_id = c.commission_orders_id"; /*v2.1.0c*/

      $orders = $db->Execute($query);      
 
      while (!$orders->EOF) {
        $commission = floatval($orders->fields['commission_rate']);
        $purchase_date = strtotime($orders->fields['date_purchased']);
        $current_date = $orders->fields['commission_paid'];
        
        $query = "SELECT t.value 
                    FROM " . TABLE_ORDERS ." o, ". TABLE_ORDERS_TOTAL ." t
                    WHERE o.orders_id = " . $orders->fields['orders_id'] . " 
                      AND o.orders_id = t.orders_id" . $totals_exclude_clause; /*v2.1.0c*/
        $totals = $db->Execute($query);
        $current_exclusion = 0;
        while (!$totals->EOF) {
          $current_exclusion += floatval($totals->fields['value']);
          
          $totals->MoveNext();
        }

        $current_amount = floatval($orders->fields['order_total']) - $current_exclusion;

        if ($current_amount < 0) {
          $current_amount = 0;
        }

        if ($current_date != "0000-00-00 00:00:00") {
          $current_date = strtotime($current_date);
        } else {
          $current_date = 0;
        }
        
        if ( $no_status_exclusions || !($current_date == 0 && in_array($orders->fields['orders_status'], $status_exclude_array)) ) {  /*v2.5.0a,v2.5.1c*/
          $total_total += $current_amount;
          $total_commission += $commission * $current_amount;

          if( $purchase_date > $year_start ) {
            $yearly_total += $current_amount;
            $yearly_commission += $commission * $current_amount;
          }
          
          if ($current_date === 0) {
            $unpaid_total += $current_amount;
            $unpaid_commission += $commission * $current_amount;
          }
          
          if ($current_date > $last_payout) {
            $last_payout = $current_date;
          }

          if ($activity_begin < $current_date && $current_date < $activity_end) {  /*v2.5.0c*/
            $activity_total += $current_amount;
            $activity_commission += $commission * $current_amount;

            array_push( $activity, array('amount' => $current_amount, 'date' => $purchase_date, 'paid' => $current_date, 'commission' => $commission) );
          }
          
        }  /*v2.5.0a*/

        $orders->MoveNext();
      }
    }
  }
}
11 Sep 2013, 5:32 PM
#109
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

v2.5.1 has been submitted to the Plugins area:

  • BUGFIX: Introduced in v2.5.0, no order details were displayed on referrers_main if the configuration contained no orders-status exclusions.
  • Updated language file for referrers_main page to make it more obvious that the activity report is based on commission payments.
  • BUGFIX: Banner images displayed using HTTP_SERVER on SSL pages, resulting in mixed-content warnings from the browser.
17 Sep 2013, 11:01 AM
#110
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

v2.5.1 is now available in the Plugins ...

21 Sep 2013, 3:35 AM
#111
jcbazemore avatar

jcbazemore

New Zenner

Join Date:
Aug 2013
Location:
Georgia
Posts:
25
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

I've read though the whole thread so far and I'm looking forward to adding this to my site. Since our site is being setup so that organizations (booster clubs, youth groups, churches, etx) can sell our products as a fundraiser is there a way to "force" someone shopping on our site to use an affiliate? We do not want to sell the products ourselves but only through the groups that are doing business with us.

21 Sep 2013, 6:28 AM
#112
picandnix avatar

picandnix

Totally Zenned

Join Date:
Dec 2010
Location:
UK
Posts:
1,780
Plugin Contributions:
2

Re: Snap Affiliates v2.0 for v1.5.0 and later

jcbazemore:

I've read though the whole thread so far and I'm looking forward to adding this to my site. Since our site is being setup so that organizations (booster clubs, youth groups, churches, etx) can sell our products as a fundraiser is there a way to "force" someone shopping on our site to use an affiliate? We do not want to sell the products ourselves but only through the groups that are doing business with us.

This mod, in basic terms, is a way for your affiliates to direct a potential customer to YOUR site to buy the product from YOU, the affiliate then earns a commission on the sale they sent your way.
So how can a customer buy something if YOU aren't selling?

21 Sep 2013, 10:41 AM
#113
jcbazemore avatar

jcbazemore

New Zenner

Join Date:
Aug 2013
Location:
Georgia
Posts:
25
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

picandnix:

This mod, in basic terms, is a way for your affiliates to direct a potential customer to YOUR site to buy the product from YOU, the affiliate then earns a commission on the sale they sent your way.
So how can a customer buy something if YOU aren't selling?

Sorry, that could have been a bit clearer on my part. It is products that we're selling but since the point of our business is to help organizations raise money we don't want to be in "competition" with them on the sale of our products. Our business is not selling coffee, our business is helping THEM to sell coffee as a fundraiser. For example, our first client is a High School Football team booster club. We want people to come to our site not to buy coffee from us, but to buy coffee from them and we're just the one's handling the transaction. We want to make sure that if someone just stumbles across our site or types in the root site name without using the affiliate link that they have to select that High School Booster club to purchase from. Of course our goal is to have many many of these type booster clubs or other groups signed up with us. Then, if someone comes to our site directly they'll have to "choose" their affiliate. Hopefully that makes things a little clearer than mud!

21 Sep 2013, 11:42 AM
#114
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

@jcbazemore, it'll take some custom coding but it should be doable. When a customer comes to your site via an affiliate, their initial link has the affiliate's "key" as part of the link variables. That "key" is stored in a cookie in the client's browser, so it's detectable -- in fact, that's what /includes/init_includes/init_snap.php does, looking for a cookie with your store's defined cookie-prefix and setting a session variable if the cookie's present.

Essentially, my interpretation of what you want is that the store operates like a "normal" Zen Cart if the customer has an affiliate cookie loaded and operates like a showcase with prices otherwise (see the setting Configuration->My Store->Store Status). If you use your admin's Tools->Developers Toolkit and search for STORE_STATUS in all catalog PHP files, you'll see the list (not too many) of files that use and process based on that variable. You'll need to make modifications to (or around) each of those files, replacing the STORE_STATUS processing based on the presence/absence of the affiliate cookie.

My guess at an initial look is that you'd want to go down the path of setting your database's "Store Status" to "Showcase with Prices" and make changes to the necessary core files to switch back to "normal" if the cookie is present.

21 Sep 2013, 2:46 PM
#115
buggypy1 avatar

buggypy1

New Zenner

Join Date:
Sep 2013
Posts:
2
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

Hello Everyone,
My customers cannot open the affiliate signup page and it is not showing in their accounts also.
I have install all the files as mentioned in the readme file.
I have tried it by using this sample mentioned https://www.mysite.com/index.php?main_page=referrer_signup&terms
My website is https://www.247donny.com
Can someone help me with this please?
Thanks.

21 Sep 2013, 4:44 PM
#116
picandnix avatar

picandnix

Totally Zenned

Join Date:
Dec 2010
Location:
UK
Posts:
1,780
Plugin Contributions:
2

Re: Snap Affiliates v2.0 for v1.5.0 and later

buggypy1:

Hello Everyone,
My customers cannot open the affiliate signup page and it is not showing in their accounts also.
I have install all the files as mentioned in the readme file.
I have tried it by using this sample mentioned https://www.mysite.com/index.php?main_page=referrer_signup&terms
My website is https://www.247donny.com
Can someone help me with this please?
Thanks.

I can see that you haven't uploaded all the files fully.

21 Sep 2013, 5:04 PM
#117
buggypy1 avatar

buggypy1

New Zenner

Join Date:
Sep 2013
Posts:
2
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

picandnix:

I can see that you haven't uploaded all the files fully.

I have upload all the files in Images, Includes and Your admin.

Can you please let me know which one is still missing?

Thanks.

21 Sep 2013, 7:17 PM
#118
jcbazemore avatar

jcbazemore

New Zenner

Join Date:
Aug 2013
Location:
Georgia
Posts:
25
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

lat9:

@jcbazemore, it'll take some custom coding but it should be doable. When a customer comes to your site via an affiliate, their initial link has the affiliate's "key" as part of the link variables. That "key" is stored in a cookie in the client's browser, so it's detectable -- in fact, that's what /includes/init_includes/init_snap.php does, looking for a cookie with your store's defined cookie-prefix and setting a session variable if the cookie's present.

Essentially, my interpretation of what you want is that the store operates like a "normal" Zen Cart if the customer has an affiliate cookie loaded and operates like a showcase with prices otherwise (see the setting Configuration->My Store->Store Status). If you use your admin's Tools->Developers Toolkit and search for STORE_STATUS in all catalog PHP files, you'll see the list (not too many) of files that use and process based on that variable. You'll need to make modifications to (or around) each of those files, replacing the STORE_STATUS processing based on the presence/absence of the affiliate cookie.

My guess at an initial look is that you'd want to go down the path of setting your database's "Store Status" to "Showcase with Prices" and make changes to the necessary core files to switch back to "normal" if the cookie is present.

@lat9 I'm glad to hear it's doable and I'm sure I'll be bothering you more for details as I get stuck. Until I've got it worked out my workaround is to duplicate each item for each client adding "-client id" to the end of the product Model Number. Luckily we just have the one client so far and only four items. It won't be trackable via their affiliate page, but they'll at least get credit from us when someone buys "Irish Crème-fchstdc" vs "Irish Crème-fchscheer"

24 Sep 2013, 8:35 PM
#119
jcbazemore avatar

jcbazemore

New Zenner

Join Date:
Aug 2013
Location:
Georgia
Posts:
25
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

Hey Lat9 I just found out last night that instead of four products we're going to have about 15 products at launch. This being said I have a feature request for future versions (unless there's something I can modify to make this happen now.) Is it possible to have the referrer code listed somewhere on the invoice? We offer custom labeling for our coffee's and the label is determined by which organization the order is placed for. I know I can tell that by clicking on the referrer link next to the order in the Admin section, but it would be easier if we could see it on the invoices that are printed out and not be tied to a computer when slapping on labels!

25 Sep 2013, 11:00 AM
#120
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

jcbazemore:

Hey Lat9 I just found out last night that instead of four products we're going to have about 15 products at launch. This being said I have a feature request for future versions (unless there's something I can modify to make this happen now.) Is it possible to have the referrer code listed somewhere on the invoice? We offer custom labeling for our coffee's and the label is determined by which organization the order is placed for. I know I can tell that by clicking on the referrer link next to the order in the Admin section, but it would be easier if we could see it on the invoices that are printed out and not be tied to a computer when slapping on labels!
Here's a snippet of code that determines whether an order included a commission and returns the referrer's code (or false if no code was found):

function get_referrer_key($oID) {
    // -----
    // Check to see if the specified order has an associated referrer commission ...
    //
    $sa_sql = 'SELECT r.referrer_key 
                 FROM ' . TABLE_REFERRERS . ' r, ' . TABLE_COMMISSION . ' rc 
                 WHERE rc.commission_orders_id = ' . (int)$oID . '
                 AND rc.commission_referrer_key = r.referrer_key;

    $sa_info = $db->Execute($sa_sql);

    return ($sa_info->EOF) ? false : $sa_info->fields['referrer_key'];
}

and then use that function in /YOUR_ADMIN/invoice.php (for v1.5.1 around line 132), changing:

  <tr>
    <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>
  <tr>
    <td class="main"><b><?php echo ENTRY_ORDER_ID . $oID; ?></b></td>
  </tr>
  <tr>
    <td><table border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td class="main"><strong><?php echo ENTRY_DATE_PURCHASED; ?></strong></td>
        <td class="main"><?php echo zen_date_long($order->info['date_purchased']); ?></td>
      </tr>
      <tr>
        <td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b></td>
        <td class="main"><?php echo $order->info['payment_method']; ?></td>
      </tr>

to

  <tr>
    <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>
  <tr>
    <td class="main"><b><?php echo ENTRY_ORDER_ID . $oID; ?></b></td>
  </tr>
  <tr>
    <td><table border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td class="main"><strong><?php echo ENTRY_DATE_PURCHASED; ?></strong></td>
        <td class="main"><?php echo zen_date_long($order->info['date_purchased']); ?></td>
      </tr>
      <tr>
        <td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b></td>
        <td class="main"><?php echo $order->info['payment_method']; ?></td>
      </tr>
<?php
if (get_referrer_key($oID) !== false) {
?>
      <tr>
        <td class="main"><b>Affiliate Code:</b></td>
        <td class="main"><?php echo get_referrer_key($oID); ?></td>
      </tr>
<?php
}
?>

You can place the function definition at the top of invoice.php, just after the "require" statement for application_top.php.