I would like to add the ZAR to the list of available currencies in the PayPal plugin. I can do this by hard coding.
I add 'ZAR' to PHPPlugin->lib.php->enrol_paypal_plugin->get_currencies->$codes
However this is hard coding and I have been told to stay away from this in my code. Is there a more elegant and reliable method or am I limited to hard coding.
(Also will upgrading the plugin force me to re-add this code)
Thank you
You can't change that list without editing the file you have mentioned.
If you plan on upgrading Moodle by downloading the latest code and manually replacing the existing code, then your changes would get overwritten. However, if you switch to maintaining your site code via Git ( https://docs.moodle.org/27/en/Git_for_Administrators ), then it is possible to maintain such changes during upgrades (although core changes should still be avoided, if possible).
I do note, however, that ZAR doesn't appear to be in the list of currencies supported by the PayPal API: https://developer.paypal.com/webapps/developer/docs/classic/api/currency_codes/
So, I'm not convinced that it will work, even if you add it (but happy to be corrected on that front).