Dave_in_the_UK Posted January 27, 2004 Share Posted January 27, 2004 Sorry if this has been covered before...I couldn't see an answer anywhere when I searched for it. The issue crops up regularly of how to restrict payment methods according to country (e.g. NoChex is only available in the UK) - this has been answered elsewhere. However, it seems to me, that what I really want is the ability to restrict payment methods according to the customer's currency. For example, just because my buyer is in France, then I don't want to stop him using NoChex if he has a valid NoChex account and is paying in GBP. Similarly, if someone is in Australia but has a UK bank account and sends me a UK bank cheque in GBP then that is fine also. After some head-scratching the changes to be made are quite simple. Taking the NoChex module as an example: First uninstall NoChex from the admin screen->modules->payment if it is already installed. Now you need to edit some code. Edit catalogue/includes/modules/payment/nochex.php as follows: Replace: if ($check_flag == false) { $this->enabled = false; } } } With: if ($check_flag == false) { $this->enabled = false; } } // // BEGIN Payment Method Currency mod - dgjw 26/1/04 - Check for valid currency code for this payment method // if (tep_not_null(MODULE_PAYMENT_NOCHEX_CURRENCIES)) { global $currency; $my_currencies = explode(',', MODULE_PAYMENT_NOCHEX_CURRENCIES); if (!in_array($currency, $my_currencies)) { $this->enabled = false; } } // // END } Find the section (near the bottom of the file): function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable NOCHEX Module', 'MODULE_PAYMENT_NOCHEX_STATUS', 'True', 'Do you want to accept NOCHEX payments?', '6', '3', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('E-Mail Address', 'MODULE_PAYMENT_NOCHEX_ID', 'you@yourbuisness.com', 'The e-mail address to use for the NOCHEX service', '6', '4', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_NOCHEX_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_NOCHEX_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_NOCHEX_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())"); } BEFORE the closing } INSERT tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Allowed Currencies', 'MODULE_PAYMENT_NOCHEX_CURRENCIES', '', 'If entered, only enable this payment method for those listed - separate with commas and no spaces!', '6', '2', now())"); // dgjw 26/1/04 - Payment Method Currencies mod Replace: function keys() { return array('MODULE_PAYMENT_NOCHEX_STATUS', 'MODULE_PAYMENT_NOCHEX_ID', 'MODULE_PAYMENT_NOCHEX_ZONE', 'MODULE_PAYMENT_NOCHEX_ORDER_STATUS_ID', 'MODULE_PAYMENT_NOCHEX_SORT_ORDER'); } With: function keys() { return array('MODULE_PAYMENT_NOCHEX_STATUS', 'MODULE_PAYMENT_NOCHEX_ID', 'MODULE_PAYMENT_NOCHEX_ZONE', 'MODULE_PAYMENT_NOCHEX_CURRENCIES', 'MODULE_PAYMENT_NOCHEX_ORDER_STATUS_ID', 'MODULE_PAYMENT_NOCHEX_SORT_ORDER'); // dgjw 26/1/04 - Payment Method Currencies mod } Now go back to the admin screen->modules->payment and (re-)install NoChex. You will now see a new option for "Allowed Currencies". Enter a list of those currencies allowed for this payment method (e.g. GBP) - separate a list with commas and no spaces (e.g. GBP,EUR,CAD) - and click on "Update". That's it! NoChex will now only be shown to the customer if their selected currency is in the list you entered otherwise it won't appear. You can combine this with the 'Payment Zone' method if you want further to restrict the payment methods allowed: e.g. I have a payment method of "Online banking" which is set to 'Payment Zone=UK Only' and 'Allowed Currencies=GBP'. Thus the customer can only use this payment method is she is both in the UK and is paying in GBP. You can easily mod all your other payment modules in the same way as above - just be careful to change the MODULE_PAYMENT_NOCHEX_CURRENCIES to whatever is sensible for the one you are editing (e.g. MODULE_PAYMENT_FASTPAY_CURRENCIES for FastPay etc.) and also adjust the last edit accordingly (all you are doing is adding 'MODULE_PAYMENT_NOCHEX_CURRENCIES', into the list). I hope I haven't forgotten anything...! Best wishes from the seaside. Dave Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.