NishantVadgama Posted December 2, 2014 Share Posted December 2, 2014 (edited) I want to know from where the function call or identify function call such as I have situation as follows. In my module development I have override cart's getOrderTotal() method to add some surcharges as my modules requirements, so I want to call that method only if its call by Payment Methods (or say in payment hook ) ONLY. so How can I do this ? Thank You in advance. Edited December 3, 2014 by NishantVadgama (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted December 3, 2014 Share Posted December 3, 2014 Ii am afraid the only way is to run a debug backtrace and try to identify the module's name, like $dlist=debug_backtrace(false); $dlist=array_reverse($dlist); foreach($dlist AS $trace){ if(isset($trace['file']) && stristr($trace['file'], 'modules')){ $name=explode(DIRECTORY_SEPARATOR, $trace['file']); $names[]=pSQL($name[array_search('modules', $name)+1]); } } Link to comment Share on other sites More sharing options...
NishantVadgama Posted December 4, 2014 Author Share Posted December 4, 2014 (edited) Thanks Nemo1. your suggestion is pretty good. But the problem is I am getting name AFTER function call by that module or controller. If I want to do something on that function call then I am not able to do with this code. Edited December 4, 2014 by NishantVadgama (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted December 5, 2014 Share Posted December 5, 2014 but it works that way, I created a small fees module using it, that comes straight out of my module Link to comment Share on other sites More sharing options...
NishantVadgama Posted December 5, 2014 Author Share Posted December 5, 2014 (edited) thanks nemo it really helps me a lot. so that I am marking it as solved Edited December 5, 2014 by NishantVadgama (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now