titan
11th September 2006, 05:20 PM
I fix the problems in my previous 'patch' :wink:
Now oscommerce send to pap3 ids and quantity. Pap3 will scan all the ids and if it is in some campains, calc a new commission ($ x quantity) . For each found id, build a new sell in the panel.
It work only with ProductID enabled and fixed commission not percentual.
This modify are working with the original pap3 files
Edit SaleRegistrator.class.php in pap3 and find
function registerSale($totalCost, $OrderID, $ProductID)
replace with:
function registerSale($totalCost, $OrderID, $ProductID,$Qty=1,$Fraud=true)
find
if(!$this->applyFraudProtection($ip, $status, $OrderID)) {
replace with:
if($Fraud && !$this->applyFraudProtection($ip, $status, $OrderID)) {
find
$commission = $this->computeCommission($totalCost, $this->PerSaleCommType, $this->SaleCommission);
replace with
if($ProductID != '' && $this->settings['Aff_forcecommfromproductid'] == 'yes' && $this->PerSaleCommType=="$")
$commission = $this->computeCommission($totalCost, $this->PerSaleCommType, $this->SaleCommission*$Qty);
else
$commission = $this->computeCommission($totalCost, $this->PerSaleCommType, $this->SaleCommission);
Edit sale.php and find
$saleReg->registerSale($TotalCost, $OrderID, $ProductID);
replace with
if(!empty($ProductID))
{
$ListSales=(strpos($ProductID,";")!==false)?split(";",$ProductID):array($ProductID);
$Fraud=true;
foreach($ListSales as $sSale){
list($ProductID,$Qty)=split(":",$sSale);
$saleReg->registerSale($TotalCost, $OrderID, $ProductID, $Qty, $Fraud);
$Fraud=false;
}
}
else
QCore_History::logWithCondition($debug_sales == 1, WLOG_DEBUG, "Sale registration: ProductID not present", __FILE__, __LINE__);
Edit checkout_process.php in oscommerce and
in the begining , after
<?php
insert :
unset($_SESSION['PAP3']);
find:
$products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";
and after insert:
$_SESSION['PAP3']['id'][$i]=$order->products[$i]['id'] ; // AFFILIATE PAP3
$_SESSION['PAP3']['qty'][$i]=$order->products[$i]['qty'] ; // AFFILIATE PAP3
Edit checkout_success in oscommerce , find the pap3 routine and replace with
//--------------------------------------------------------------------------
// integration code
//--------------------------------------------------------------------------
// get order id
$sql = "select orders_id from ".TABLE_ORDERS.
" where customers_id='".(int)$customer_id.
"' order by date_purchased desc limit 1";
$pap_orders_query = tep_db_query($sql);
$pap_orders = tep_db_fetch_array($pap_orders_query);
$pap_order_id = $pap_orders['orders_id'];
$pap_order_listid="";
if(isset($_SESSION['PAP3']['id']) && !empty($_SESSION['PAP3']['id']))
foreach($_SESSION['PAP3']['id'] as $n => $id)
{
$pap_order_listid.=$id.":".$_SESSION['PAP3']['qty'][$n].";";
}
$pap_order_listid=substr($pap_order_listid,0,strle n($pap_order_listid)-1);
// get total amount of order
$sql = "select value from ".TABLE_ORDERS_TOTAL.
" where orders_id='".(int)$pap_order_id.
"' and class='ot_subtotal'";
$pap_orders_total_query = tep_db_query($sql);
$pap_orders_total = tep_db_fetch_array($pap_orders_total_query);
$pap_total_value = $pap_orders_total['value'];
// draw invisible image to register sale
if($pap_total_value != "" && $pap_order_id != "")
{
$img = '<script id="pap_xxxxxxxxx" src="http://www.domain.ext/adv/scripts/sale.js" type="text/javascript"></script>
<script type="text/javascript"><!--
var TotalCost="'.$pap_total_value.'";
var OrderID="'.$pap_order_id.'";
var ProductID="'.$pap_order_listid.'";
papSale();
--></script>';
print $img;
unset($_SESSION['PAP3']);
}
//--------------------------------------------------------------------------
// END of integration code
//--------------------------------------------------------------------------
(remember to modify the script id and img src with your datas.)
Now oscommerce send to pap3 ids and quantity. Pap3 will scan all the ids and if it is in some campains, calc a new commission ($ x quantity) . For each found id, build a new sell in the panel.
It work only with ProductID enabled and fixed commission not percentual.
This modify are working with the original pap3 files
Edit SaleRegistrator.class.php in pap3 and find
function registerSale($totalCost, $OrderID, $ProductID)
replace with:
function registerSale($totalCost, $OrderID, $ProductID,$Qty=1,$Fraud=true)
find
if(!$this->applyFraudProtection($ip, $status, $OrderID)) {
replace with:
if($Fraud && !$this->applyFraudProtection($ip, $status, $OrderID)) {
find
$commission = $this->computeCommission($totalCost, $this->PerSaleCommType, $this->SaleCommission);
replace with
if($ProductID != '' && $this->settings['Aff_forcecommfromproductid'] == 'yes' && $this->PerSaleCommType=="$")
$commission = $this->computeCommission($totalCost, $this->PerSaleCommType, $this->SaleCommission*$Qty);
else
$commission = $this->computeCommission($totalCost, $this->PerSaleCommType, $this->SaleCommission);
Edit sale.php and find
$saleReg->registerSale($TotalCost, $OrderID, $ProductID);
replace with
if(!empty($ProductID))
{
$ListSales=(strpos($ProductID,";")!==false)?split(";",$ProductID):array($ProductID);
$Fraud=true;
foreach($ListSales as $sSale){
list($ProductID,$Qty)=split(":",$sSale);
$saleReg->registerSale($TotalCost, $OrderID, $ProductID, $Qty, $Fraud);
$Fraud=false;
}
}
else
QCore_History::logWithCondition($debug_sales == 1, WLOG_DEBUG, "Sale registration: ProductID not present", __FILE__, __LINE__);
Edit checkout_process.php in oscommerce and
in the begining , after
<?php
insert :
unset($_SESSION['PAP3']);
find:
$products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";
and after insert:
$_SESSION['PAP3']['id'][$i]=$order->products[$i]['id'] ; // AFFILIATE PAP3
$_SESSION['PAP3']['qty'][$i]=$order->products[$i]['qty'] ; // AFFILIATE PAP3
Edit checkout_success in oscommerce , find the pap3 routine and replace with
//--------------------------------------------------------------------------
// integration code
//--------------------------------------------------------------------------
// get order id
$sql = "select orders_id from ".TABLE_ORDERS.
" where customers_id='".(int)$customer_id.
"' order by date_purchased desc limit 1";
$pap_orders_query = tep_db_query($sql);
$pap_orders = tep_db_fetch_array($pap_orders_query);
$pap_order_id = $pap_orders['orders_id'];
$pap_order_listid="";
if(isset($_SESSION['PAP3']['id']) && !empty($_SESSION['PAP3']['id']))
foreach($_SESSION['PAP3']['id'] as $n => $id)
{
$pap_order_listid.=$id.":".$_SESSION['PAP3']['qty'][$n].";";
}
$pap_order_listid=substr($pap_order_listid,0,strle n($pap_order_listid)-1);
// get total amount of order
$sql = "select value from ".TABLE_ORDERS_TOTAL.
" where orders_id='".(int)$pap_order_id.
"' and class='ot_subtotal'";
$pap_orders_total_query = tep_db_query($sql);
$pap_orders_total = tep_db_fetch_array($pap_orders_total_query);
$pap_total_value = $pap_orders_total['value'];
// draw invisible image to register sale
if($pap_total_value != "" && $pap_order_id != "")
{
$img = '<script id="pap_xxxxxxxxx" src="http://www.domain.ext/adv/scripts/sale.js" type="text/javascript"></script>
<script type="text/javascript"><!--
var TotalCost="'.$pap_total_value.'";
var OrderID="'.$pap_order_id.'";
var ProductID="'.$pap_order_listid.'";
papSale();
--></script>';
print $img;
unset($_SESSION['PAP3']);
}
//--------------------------------------------------------------------------
// END of integration code
//--------------------------------------------------------------------------
(remember to modify the script id and img src with your datas.)