SparkyRih Posted December 17, 2015 Share Posted December 17, 2015 I'm writing a payment module, so far I managed to find everything I need... But I'm stuck at the country ISO code, I can't find it... Link to comment Share on other sites More sharing options...
El Patron Posted December 17, 2015 Share Posted December 17, 2015 This is referenced by PS via back office-->localization-->countries (then click the help button) http://www.iso.org/iso/country_codes/iso_3166_code_lists/country_names_and_code_elements.htm Link to comment Share on other sites More sharing options...
SparkyRih Posted December 17, 2015 Author Share Posted December 17, 2015 Sorry I think I didn't make myself clear: I need to retrieve the ISO code within my code... I can probably do it with an SQL query to the DB, but isn't there a function (like $language->getIsoById(lang_id)) that I can use based on id_country of the customers address? Link to comment Share on other sites More sharing options...
razaro Posted December 17, 2015 Share Posted December 17, 2015 Maybe with this code $iso = Context::getContext()->language->iso_code; or $iso = Context::getContext()->cookie->iso_code_country; or use $this->context if already defined Link to comment Share on other sites More sharing options...
SparkyRih Posted December 21, 2015 Author Share Posted December 21, 2015 The language object does only contain EN and NL (not so weird since those are the languages that I support)... And the cookie object, I can't find anything in there..... But the payment method that I'm implementing does only support NL and BE at this moment... And each of thes counries require a different validation procedure, so I need to tell the payment provider which one the customer choose, but they ask for the ISO code... Link to comment Share on other sites More sharing options...
SparkyRih Posted December 22, 2015 Author Share Posted December 22, 2015 I already figured out that it is not a standard value... The only getIsoCodeById($id_lang) method that I found was inside the language object, but it only returns: 0 = EN, 1 = NL, but when a customer chooses for The Netherlands in their shipping/billing address, I get country ID = 13... So where do I find the list/array/method with all the countries, hopefully also containing the ISO code so that I can retrieve the correct COUNTRY ISO CODE for NL (in my case on ID 13)... Link to comment Share on other sites More sharing options...
SparkyRih Posted December 22, 2015 Author Share Posted December 22, 2015 As I explained earlier: I'm writing a payment module which allows my customers to "purchase now, pay later"... This payment method is provided by a new payment provider in The Netherlands (AfterPay)... So customers buy their product in my store, but the payment provider (AfterPay) will collect the money from the customer at a later point in time... So obviously AfterPay needs the customers billing information, including country, which their API wants in ISO format... So that's why the module needs the ISO code... Also, I don't want to "hack" anything since I want to release this module once it's finished so other people can simply install it, and use it without the need of setting up stuff in their PrestaShop... The module is production ready, except for the country ISO code which I have hard coded at this point since I can't figure out how to get it! :S Link to comment Share on other sites More sharing options...
SparkyRih Posted December 28, 2015 Author Share Posted December 28, 2015 Nobody knows this? Link to comment Share on other sites More sharing options...
LucieDev Posted February 7, 2020 Share Posted February 7, 2020 I know is a old post but it appears as first result for my search, I think SparkyRih need this kind of code : $cart = $this->context->cart; $address_delivery = new Address($cart->id_address_delivery); $address_delivery_country = new Country($address_delivery->id_country); $iso_code = $address_delivery_country->iso_code; Work in a payment module, in hookPayment method 2 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