DrLightman Posted March 1, 2013 Share Posted March 1, 2013 My goal is to print a conversion tracking code after a Paypal payment. It seemed easy to put the conversion tracking code in complete.tpl between {if $ispaid} and {/if}, even if a required var "amount" was missing. {if $ispaid} <!-- Enter any HTML code which needs to be displayed once a user has completed the checkout of their order here - for example conversion tracking and affiliate tracking scripts --> {/if} The problem is that after a Paypal payment on paypal.com, I'm not taken back to /cart.php?a=complete , but to the invoice /viewinvoice.php?id=xxxx , even if the "Automatically forward the user to the payment gateway" is checked in Options. Well, it's true I'm forwarded to the payment gateway, Paypal in this case, but after the payment I'm taken to the invoice rather to the complete/thank you page. In desperation, I tried to hook into InvoicePaid and made a function to echo the code there, in the invoice. But it doesn't work either, nothing is echoed. /includes/hooks/csw.php (custom file): // copy paste of function found in whmcs docs online function csw_xml_parser($rawxml) { $xml_parser = xml_parser_create(); xml_parse_into_struct($xml_parser, $rawxml, $vals, $index); xml_parser_free($xml_parser); $params = array(); $level = array(); $alreadyused = array(); $x=0; foreach ($vals as $xml_elem) { if ($xml_elem['type'] == 'open') { if (in_array($xml_elem['tag'],$alreadyused)) { $x++; $xml_elem['tag'] = $xml_elem['tag'].$x; } $level[$xml_elem['level']] = $xml_elem['tag']; $alreadyused[] = $xml_elem['tag']; } if ($xml_elem['type'] == 'complete') { $start_level = 1; $php_stmt = '$params'; while($start_level < $xml_elem['level']) { $php_stmt .= '[$level['.$start_level.']]'; $start_level++; } $php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];'; @eval($php_stmt); } } return($params); } function csw_InvoicePaid( $vars ) { $invoiceid = $vars['invoiceid']; $invoiceXML = localAPI('getinvoice',array('invoiceid'=>"$invoiceid"),'admin'); $invoice = csw_xml_parser($invoiceXML); // debug to see what invoice looks like return '<pre>'.print_r( $invoice, true ).'</pre>'; } add_hook("InvoicePaid",1,"csw_InvoicePaid"); Could anybody kindly shed some light on this thing please? Thank you in advance. 0 Quote Link to comment Share on other sites More sharing options...
Seiya Posted March 22, 2013 Share Posted March 22, 2013 Were you able to find a solution? Customers are redirected from Paypal to the invoice paid page bypassing the tracking code in the complete.tpl template. Surely this must be a common issue with Paypal being the most popular payment gateway and ecommerce tracking a necessity for most? 0 Quote Link to comment Share on other sites More sharing options...
Khairul Posted November 25, 2013 Share Posted November 25, 2013 Was there any progress done on this feature that helps businesses determine ROI? 0 Quote Link to comment Share on other sites More sharing options...
carltoncarney Posted November 26, 2013 Share Posted November 26, 2013 Thanks for sharing information. 0 Quote Link to comment Share on other sites More sharing options...
Dave_Johns Posted February 10, 2021 Share Posted February 10, 2021 I'm having the same issue. Any idea how to get the user from paypal to complete.tpl? 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.