ienabellamy Posted October 23, 2012 Share Posted October 23, 2012 (edited) Hello ! i've this portion of code in a file: validation.php $paypal->validateOrder($_POST['custom'], _PS_OS_PAYMENT_, $price, $paypal->displayName, $paypal->getL('transaction').$_POST['txn_id']); That function is declared in another file PaymentModule.php public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, $secure_key = false, Shop $shop = null) {CONTENT FUNCTION} I want that $paypal->validateOrder calls another file, for example PaymentModuleMod.php that will contains the same function little modified. in which way can i do this ? and for just curiosity, in which way the system KNOWS that validateOrder() is in PaymentModule.php ? is that $paypal-> that specify this ? Thanks, i'm trying to modify some Prestashop's modules Thanks to ALL!! p.s. i tried to integrate the function directly in the validation.php and i also tried to replace the VALUES, but doesn't work 'cause i wrong something :-/ Edited October 23, 2012 by ienabellamy Quote Link to comment https://forums.phpfreaks.com/topic/269819-specify-a-php-function/ Share on other sites More sharing options...
requinix Posted October 23, 2012 Share Posted October 23, 2012 Can't you just rename the current file to, like, PaymentModuleMod.bak.php, and move the modified version into its place? Most likely (there are other possibilities): PaymentModule.php includes the definition of some class. $paypal is an instance of that class. So when code calls $paypal->validateOrder() it'll run the code contained in that file. Quote Link to comment https://forums.phpfreaks.com/topic/269819-specify-a-php-function/#findComment-1387325 Share on other sites More sharing options...
ienabellamy Posted October 24, 2012 Author Share Posted October 24, 2012 and in which way can i specify that the function is in the same file when function is called ? like validateOrder($_POST['custom'], _PS_OS_PAYMENT_, $price, $paypal->displayName, $paypal->getL('transaction').$_POST['txn_id']); public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, $secure_key = false, Shop $shop = null) {CONTENT FUNCTION} is it correct ? because i tried and it doesn't work :-/ Quote Link to comment https://forums.phpfreaks.com/topic/269819-specify-a-php-function/#findComment-1387388 Share on other sites More sharing options...
requinix Posted October 24, 2012 Share Posted October 24, 2012 If I'm understanding you right then no, that's not possible. Try copying the file over like I said. Quote Link to comment https://forums.phpfreaks.com/topic/269819-specify-a-php-function/#findComment-1387409 Share on other sites More sharing options...
ienabellamy Posted October 24, 2012 Author Share Posted October 24, 2012 Hi all ! i solved ! i simply replicated the function, with my modifies, validateOrderMod (declared in the same class $paypal), and so, the new method is: $paypal->validateOrderMod Thanks to all, i'm real new to the Object style programming, i'm coming from old style, Ansi C, and is real difficult understand object oriented php language. Thanks to all again !!!! Quote Link to comment https://forums.phpfreaks.com/topic/269819-specify-a-php-function/#findComment-1387410 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.