Advertisement
businessdad

WooCommerce Mollie - Add currencies to the payment plugin

Oct 25th, 2017
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.42 KB | None | 0 0
  1. /**
  2.  * Mollie gateway for WooCommerce. Adds extra currencies to the "supported
  3.  * currencies" list used by the Mollie payment plugin.
  4.  *
  5.  * HOW TO USE THIS CODE
  6.  * Simply add the code to the bottom of your theme's functions.php file, and it
  7.  * will run automatically. For more information: https://www.skyverge.com/blog/add-custom-code-to-wordpress/
  8.  *
  9.  * GPL DISCLAIMER
  10.  * Because this code program is free of charge, there is no warranty for it, to the extent permitted by applicable law.
  11.  * Except when otherwise stated in writing the copyright holders and/or other parties provide the program "as is"
  12.  * without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of
  13.  * merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program
  14.  * is with you. should the program prove defective, you assume the cost of all necessary servicing, repair or correction.
  15.  *
  16.  * Need a consultation, or assistance to customise this code? Find us on Codeable: https://aelia.co/hire_us
  17.  */
  18.  
  19. /**
  20.  * Adds currencies to the list of currencies supported by Mollie.
  21.  * IMPORTANT: this will prevent the Mollie gateway from disabling itself when an
  22.  * unsupported currency is detecte, but it won't allow Mollie to accept
  23.  * payments in the added currencies
  24.  *
  25.  * @param array currencies
  26.  * @return array
  27.  */
  28. function aelia_add_mollie_currencies($currencies) {
  29.   // Add USD to the currencies supported by Mollie.
  30.   $currencies[] = 'USD';
  31.   return $currencies;
  32. }
  33.  
  34. /**
  35.  * Classes used by Mollie gateway. The class, in lower-case is also the ID of
  36.  * the gateway.
  37.  */
  38. $aelia_mollie_classes = array(
  39.   'Mollie_WC_Gateway_BankTransfer',
  40.   'Mollie_WC_Gateway_BelfiusSepaRecurring',
  41.   'Mollie_WC_Gateway_Bitcoin',
  42.   'Mollie_WC_Gateway_CreditcardSubscription',
  43.   'Mollie_WC_Gateway_DirectDebit',
  44.   'Mollie_WC_Gateway_Giftcard',
  45.   'Mollie_WC_Gateway_IdealSepaRecurring',
  46.   'Mollie_WC_Gateway_Kbc',
  47.   'Mollie_WC_Gateway_MisterCashSepaRecurring',
  48.   'Mollie_WC_Gateway_PayPal',
  49.   'Mollie_WC_Gateway_Paysafecard',
  50.   'Mollie_WC_Gateway_SofortSepaRecurring',
  51. );
  52.  
  53. // Add a filter for each of the Mollie gateways, to alter the list of supported
  54. // currencies
  55. foreach($aelia_mollie_classes as $mollie_class) {
  56.   $mollie_class = strtolower($mollie_class);
  57.   add_filter("woocommerce_{$mollie_class}_supported_currencies", 'aelia_add_mollie_currencies');
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement