Jump to content

Update Invoice Total


Burti

Recommended Posts

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");

?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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];

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated