asterisco Posted June 4, 2020 Share Posted June 4, 2020 Hello, I'm having an issue with the Paypal module, and I need to create a small module to change the currency of an order if the customer choose paying by Paypal. I'm assuming there is a hook to intercept the moment previous to calling the Paypal module so I can do the change. Does anybody know if there is one? Thanks in advance Link to comment Share on other sites More sharing options...
tomerg3 Posted June 4, 2020 Share Posted June 4, 2020 There is no pre-payment hook. Why not make the change you need directly in the PayPal module? Link to comment Share on other sites More sharing options...
asterisco Posted June 5, 2020 Author Share Posted June 5, 2020 Thanks for the answer! Yes, I believe I will try to overwrite the module itself. Link to comment Share on other sites More sharing options...
Chill_user Posted June 9, 2020 Share Posted June 9, 2020 (edited) Yes it's possible. You can change currency for example, if customer has choosen the Paypal method. You don't have hook for this. It's not so fast, but you can create some kind of "Payment module" Your steps: 1. Go to https://validator.prestashop.com/generator 2. Create !payment module!, you have all steps describe with previous link. 3. In your payment module you need to create controller. This controller will manage all data user entered. Something like this: class your_module_nameValidationModuleFrontController extends ModuleFrontController { public $ssl = true; public function initContent() { parent::initContent(); $cart = $this->context->cart; //getting values from form $billing_address = Tools::getValue('same_address'); //manage stuff here you like to change } } 4. In previously created controller you can pass an "action" before user goes to checkout and than programmatically redirect him to paypal landing page. 5. Change the template of payment step in .tpl and create the custom "payment" button whick redirects to your controller you created. OR Modify the paypal module, but pay attention to some code errors; I recommend you to create a function outside the Paypal module that modifies some info. Than just call this fuction inside paypal module. With this method you will modify only 1 line of code inside paypal module as all lines of code will be stored outside = easy dubug Edited June 9, 2020 by Amantha Bill (see edit history) Link to comment Share on other sites More sharing options...
asterisco Posted June 9, 2020 Author Share Posted June 9, 2020 Hi. Thanks for your answer! I've finally managed to achieve the currency change overriding the Paypal module. Luckily, there was already a function called needConvert that wasn't doing what I needed but with the override everyhing is working as expected. Thanks again! Link to comment Share on other sites More sharing options...
tomerg3 Posted June 9, 2020 Share Posted June 9, 2020 6 hours ago, asterisco said: Hi. Thanks for your answer! I've finally managed to achieve the currency change overriding the Paypal module. Luckily, there was already a function called needConvert that wasn't doing what I needed but with the override everyhing is working as expected. Thanks again! Good work! 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