From 80e491f1d8da209c9e779ca1f860f56804d43076 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 5 Sep 2014 16:10:29 +0200 Subject: [PATCH] fixed country ID on uc_checkout_form --- materio_user.module | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/materio_user.module b/materio_user.module index 0a374706..4ddbc7e6 100755 --- a/materio_user.module +++ b/materio_user.module @@ -476,6 +476,14 @@ function materio_user_uc_cart_checkout_form_alter(&$form, &$form_state, $form_id // dsm($member_profile, "member_profile"); $location = (object) $member_profile->field_adresse['und'][0]; + # convert country code to UC country ID (pfff) + $countries = db_query("SELECT country_id, country_iso_code_2 FROM {uc_countries} WHERE version > :version", array(':version' => 0))->fetchAllKeyed(); + foreach ($countries as $country_id => $country_code) { + if($location->country == $country_code){ + $location->uc_country_id = $country_id; + break; + } + } // dsm($location, "location"); // $phone_field = field_get_items('profile2', $member_profile, 'field_private_phone'); @@ -497,7 +505,7 @@ function materio_user_uc_cart_checkout_form_alter(&$form, &$form_state, $form_id "billing_city" => $location->locality, // "billing_zone" => , "billing_postal_code" => $location->postal_code, - "billing_country" => $location->country, + "billing_country" => $location->uc_country_id, ); foreach ($correspondances as $order_field => $value) {