Burti Posted December 4, 2013 Share Posted December 4, 2013 Hello, If new invoice created and paymentmethod=paypal {add the $3.00 + invoice total } But my function does not working please help me <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function addcommission($vars) { $paymentmethod = $vars['paymentmethod']; if($paymentmethod=="paypal"){ $userid = $vars['userid']; $where1 = array("userid"=>$userid); $result1 = select_query('tblinvoices','subtotal',$where1); $data = mysql_fetch_array($result); $subtotal = $data['subtotal']; $invoiceid = $vars['invoiceid']; $addvalue="3.00"; $add_commission = $subtotal+$addvalue; $table = "tblinvoices"; $update = array("subtotal"=>$add_commission); $where = array("invoiceid"=>$invoiceid,"status"=>"Unpaid"); update_query($table,$update,$where); } return; } // Define Client Logout Hook Call add_hook("InvoiceCreated",0,"addcommission"); ?> 0 Quote Link to comment Share on other sites More sharing options...
Burti Posted December 4, 2013 Author Share Posted December 4, 2013 okey im change the code but i don't get it the user id! testing code: <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function komisyonekle($vars) { $paymentmethod = $vars['paymentmethod']; $userid = $vars['param']['userid']; $invoiceid = $vars['invoiceid']; if($paymentmethod=="paypal"){ $topla='userid:'.$userid.' - invoiceid:'.$invoiceid.''; update_query( "atablo", array("gelen" => $topla), array( "id" => "1" ) ); //mysql_query("UPDATE atablo SET gelen='$topla' WHERE id='1'"); } } // Define Client Logout Hook Call add_hook("PreCalculateCartTotals",1,"komisyonekle"); ?> - - - Updated - - - I was try the: $userid = $vars['param']['userid']; $userid = $vars['params']['userid']; $userid = $vars['userid']; not working 0 Quote Link to comment Share on other sites More sharing options...
alaali Posted December 5, 2013 Share Posted December 5, 2013 Hi, InvoiceCreated action hook just have invoiceid. You will need to look for the userid using a query. The same for PreCalculateCartTotals action hook. Try to use InvoiceCreated action hook and look for userid, try this code: $table = "tblinvoices"; $fields = "userid"; $where = array("id"=>$vars['invoiceid']); $result = select_query($table,$fields,$where); $data = mysql_fetch_array($result); $userid = $data[''userid]; 0 Quote Link to comment Share on other sites More sharing options...
Burti Posted December 8, 2013 Author Share Posted December 8, 2013 Hi, InvoiceCreated action hook just have invoiceid. You will need to look for the userid using a query. The same for PreCalculateCartTotals action hook. Try to use InvoiceCreated action hook and look for userid, try this code: $table = "tblinvoices"; $fields = "userid"; $where = array("id"=>$vars['invoiceid']); $result = select_query($table,$fields,$where); $data = mysql_fetch_array($result); $userid = $data[''userid]; Thank you alaali. Also how I get the addonexample_config arrays? function addonexample_config() { $configarray = array( "name" => "Paypal Addons", "description" => "paypal addons.", "version" => "1.0", "author" => "BurtiNET", "language" => "turkish", "fields" => array( "komisyon" => array ("FriendlyName" => "Commission", "Type" => "text", "Size" => "25", "Description" => "yüzde eki girmeden yüzde kaç komisyon alacağınızı yazınız. Örnek: 15", "Default" => "3", ), )); return $configarray; } I need the fields > Commission ? how I get the rows in the hooks ? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.