Jump to content

Country Iso Code


SparkyRih

Recommended Posts

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

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

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

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

  • 4 years later...

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

  • Thanks 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...