Hi all,

I am working on eCommerce platform where user registers and defines their country (Country Field) once this is done what I need to do that the only country available for their Shipping & Billing address are that country from $user. And if there is no defined country (like Anonymous user) the only country available is for instance US.

I have managed to achieve this but the code is buggy and sometimes does odd things (especially as different countries needs different fields). I really would like to do this properly in Drupal manner.

Can somebody suggest a correct Drupal way to achieve this? Or whether something similar has been already achieved. Any advise would be great

I will be much appreciated
Povilas

Comments

puogintas created an issue. See original summary.

invincible1388’s picture

Use :

function hook_addressfield_default_values_alter(&$default_values, $context) {

$default_values['country'] = "FR";

}

Povilas Uogintas’s picture

Thank you,

Sorry for late reply. this seems to work well.

Thanks,
Pov

igorski’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.