PDA

View Full Version : Other BETTER way for ProductID and OSCOMMERCE


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.)

anh
14th September 2006, 04:25 PM
thanks, we will test it and add to next release

titan
14th September 2006, 05:01 PM
in next release? :O WoW :) :)

MurgtalNet
12th February 2007, 03:33 PM
That is a beautiful beginning.

I have the Contributions modified for OSIS-Shop, is based on osCommerce.

Characteristics added:
- proportional (%) commission for each product possible
- different commissions
- considers the fraud protection
- considers the product price !

There are only few differences too osCommerce,therefore it can be simply also used for it.

I will document it and here posts in few days.

Many greetings
Webmaster of http://www.tyrax.de/?aid=2 ;-)

Translated with Google :-))

drakeman
13th February 2007, 02:14 PM
Hello,
thank you for this solution. We appreciate it.

amstaff
21st January 2008, 05:49 PM
what is (script id and img src with your datas.)
I just add my site location but i dont understand what is script id, sorry i am a beginner :-)
Thanks

drakeman
27th January 2008, 10:56 PM
script id - it's a ID from your integration code. As ID you can use: pap_x2s6df8d

amstaff
29th January 2008, 01:36 PM
I get this error when i am at finish order in checkout_process.php

1146 - Table 'Sql81948_1.TABLE_AFFILIATE' doesn't exist

select affiliate_commission_percent from TABLE_AFFILIATE where affiliate_id = ''

[TEP STOP]

Some Help?

drakeman
13th March 2008, 11:14 PM
I don't know where this problem can be because we never tested this modification. If you are able to write a simple code in PHP, I recommend to create a new code without PAP code editing. That's not a good solution. You have to change sale tracking code only