[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/includes/ -> affiliate_checkout_process.php (source)

   1  <?php
   2  /*

   3  $Id: affiliate_checkout_process.php 14 2006-07-28 17:42:07Z user $

   4  

   5    OSC-Affiliate

   6  

   7    Contribution based on:

   8  

   9    osCMax Power E-Commerce

  10    http://oscdox.com

  11  

  12    Copyright 2006 osCMax

  13  

  14    Released under the GNU General Public License

  15  */
  16  
  17  // fetch the net total of an order

  18    $affiliate_total = 0;
  19    for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
  20      $affiliate_total += $order->products[$i]['final_price'] * $order->products[$i]['qty'];
  21    }
  22    $affiliate_total = tep_round($affiliate_total, 2);
  23  
  24  // Check for individual commission

  25    $affiliate_percentage = 0;
  26    if (AFFILATE_INDIVIDUAL_PERCENTAGE == 'true') {
  27      $affiliate_commission_query = tep_db_query ("select affiliate_commission_percent from " . TABLE_AFFILIATE . " where affiliate_id = '" . $affiliate_ref . "'");
  28      $affiliate_commission = tep_db_fetch_array($affiliate_commission_query);
  29      $affiliate_percent = $affiliate_commission['affiliate_commission_percent'];
  30    }
  31    if ($affiliate_percent < AFFILIATE_PERCENT) $affiliate_percent = AFFILIATE_PERCENT;
  32    $affiliate_payment = tep_round(($affiliate_total * $affiliate_percent / 100), 2);
  33     
  34    if ($HTTP_SESSION_VARS['affiliate_ref']) {
  35      $sql_data_array = array('affiliate_id' => $affiliate_ref,
  36                              'affiliate_date' => $affiliate_clientdate,
  37                              'affiliate_browser' => $affiliate_clientbrowser,
  38                              'affiliate_ipaddress' => $affiliate_clientip,
  39                              'affiliate_value' => $affiliate_total,
  40                              'affiliate_payment' => $affiliate_payment,
  41                              'affiliate_orders_id' => $insert_id,
  42                              'affiliate_clickthroughs_id' => $affiliate_clickthroughs_id,
  43                              'affiliate_percent' => $affiliate_percent,
  44                              'affiliate_salesman' => $affiliate_ref);
  45      tep_db_perform(TABLE_AFFILIATE_SALES, $sql_data_array);
  46  
  47      if (AFFILATE_USE_TIER == 'true') {
  48        $affiliate_tiers_query = tep_db_query ("SELECT aa2.affiliate_id, (aa2.affiliate_rgt - aa2.affiliate_lft) as height
  49                                                        FROM affiliate_affiliate AS aa1, affiliate_affiliate AS aa2
  50                                                        WHERE  aa1.affiliate_root = aa2.affiliate_root 
  51                                                              AND aa1.affiliate_lft BETWEEN aa2.affiliate_lft AND aa2.affiliate_rgt
  52                                                              AND aa1.affiliate_rgt BETWEEN aa2.affiliate_lft AND aa2.affiliate_rgt
  53                                                              AND aa1.affiliate_id =  '" . $affiliate_ref . "'
  54                                                        ORDER by height asc limit 1, " . AFFILIATE_TIER_LEVELS . " 
  55                                                ");
  56        $affiliate_tier_percentage = split("[;]" , AFFILIATE_TIER_PERCENTAGE);
  57        $i=0;
  58        while ($affiliate_tiers_array = tep_db_fetch_array($affiliate_tiers_query)) {
  59  
  60          $affiliate_percent = $affiliate_tier_percentage[$i];
  61          $affiliate_payment = tep_round(($affiliate_total * $affiliate_percent / 100), 2);
  62          if ($affiliate_payment > 0) {
  63            $sql_data_array = array('affiliate_id' => $affiliate_tiers_array['affiliate_id'],
  64                                    'affiliate_date' => $affiliate_clientdate,
  65                                    'affiliate_browser' => $affiliate_clientbrowser,
  66                                    'affiliate_ipaddress' => $affiliate_clientip,
  67                                    'affiliate_value' => $affiliate_total,
  68                                    'affiliate_payment' => $affiliate_payment,
  69                                    'affiliate_orders_id' => $insert_id,
  70                                    'affiliate_clickthroughs_id' => $affiliate_clickthroughs_id,
  71                                    'affiliate_percent' => $affiliate_percent,
  72                                    'affiliate_salesman' => $affiliate_ref);
  73            tep_db_perform(TABLE_AFFILIATE_SALES, $sql_data_array);
  74          }
  75          $i++;
  76        }
  77      }
  78    }
  79  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7