Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Add-on error when closing PHP tag. Rate Topic   - - - - -

 
  • jrchew
  • Newbie
  • Trial users
  • Join Date: 25-Jan 12
  • 8 posts

Posted 28 March 2012 - 07:45 PM #1

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

<?xml version="1.0"?>
<addon scheme='2.0'>
	<id>infusionsoft</id>
	<name>(Wally's Custom) InfusionSoft</name>
	<description>Sends customer and sales order information to InfusionSoft.</description>
	<priority>0</priority>
	<position>0</position>
	<status>active</status>
	<version>1.0</version>
	<dependencies></dependencies>
</addon>



init.php

<?php

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

  fn_register_hooks(
	'send_order_notification'  
  );

?>



func.php

<?php	

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

function fn_infusionsoft_send_order_notification($order_info){


  return 0;
}
?>


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 29 March 2012 - 06:01 AM #2

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 <?php then it will show the corresponding '?>' in the html....

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • jrchew
  • Newbie
  • Trial users
  • Join Date: 25-Jan 12
  • 8 posts

Posted 29 March 2012 - 05:40 PM #3

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.

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 29 March 2012 - 10:46 PM #4

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

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.