From 0f3912f6fd3ce75bac2fa61c0ed46e2fb334c566 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Thu, 11 Jul 2019 21:52:12 +0200 Subject: [PATCH] fixed tax country related bug in checkout --- .../gui/materiobasemod/materio_user.module | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sites/all/modules/gui/materiobasemod/materio_user.module b/sites/all/modules/gui/materiobasemod/materio_user.module index 697efcff..24df4af8 100755 --- a/sites/all/modules/gui/materiobasemod/materio_user.module +++ b/sites/all/modules/gui/materiobasemod/materio_user.module @@ -529,6 +529,32 @@ function materio_user_flatenize_form_values($ar_src, &$flat_ar){ } } +function materio_user_uc_cart_checkout_start($order) { + // dsm($order); + $user = user_load($order->uid); + // dsm($user, 'user'); + $member_profile = profile2_load_by_user($user, 'adherent'); + // 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; + } + } + + $correspondances = array( + "billing_country" => $location->uc_country_id, + ); + // dsm($correspondances); + foreach ($correspondances as $order_field => $value) { + $order->{$order_field} = $value; + } +} + /** * Implements hook_form_alter(). */