Add-on error when closing PHP tag.

Pardon if this is the wrong place to post this but for some reason I cannot post in the developers corner.



I am developing a custom add-on and have run into an interesting issue. Any time I close out my PHP tag in func.php it results in errors during the checkout process. (Error Oops, something went wrong (parsererror). Please try again.)



If I exclude the closing ?> tag my module loads just fine. Can anyone tell me what's going on? I experienced this problem in 2.x and now in 3.0.1 RC1.



My full code is posted below. Any help is appreciated. Thanks everyone!





addon.xml




infusionsoft
(Wally's Custom) InfusionSoft
Sends customer and sales order information to InfusionSoft.
0
0
active
1.0









init.php



if(!defined('AREA')){ exit('Access denied'); }

fn_register_hooks(
'send_order_notification'
);

?>








func.php



if(!defined('AREA')){ exit('Access denied'); }

function fn_infusionsoft_send_order_notification($order_info){


return 0;
}
?>

What does your error_log say about what the error is that is causing the parsererror? It sounds like you did not open one somewhere. Do a view-source and look for 'php' or '?>'. I believe that if there was no opening ' in the html…

Good observation tbirnset. I checked for any unclosed tags. None that I could find. I'm using a fresh install with no custom add-ons except for this one that I'm working on. Just checked the error_log. Nothing related to cs-cart reported any errors.



The fact that the add-on is working as it should is a good thing. I'm just not sure I want to roll it into a production environment with an unclosed PHP tag like that. Sounds like a disaster waiting to happen.



On that same note, I removed the ending PHP tag from func.php in the google_analytics add-on and it continued to work like normal as well…



Could it be that all cs-cart add-ons don't require closing PHP tags? My next attempt to solve this will require me to look into how cs-cart loads it's add-ons.

I think your statement about a disaster waiting to happen is accurate. There is an issue and leaving off the closing tag to solve it is simply lighting the fuse…