Disable Specific States in Ubercart
Here’s a quick example that illustrates how to remove a few State/Province options from the billing and shipping panes of the Ubercart checkout form, as well as the order edit/create form. Please understand there are other ways to do this (like altering the united_states_840_1.cif file and re-importing). The hook_form_alter() method seems less permanent, so I favor it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
/** * Implementation of hook_form_alter(). */ function mymodule_form_alter(&$form, &$form_state, $form_id) { switch ($form_id) { case 'uc_cart_checkout_form': // Disable some State/Province values in the checkout form unset($form['panes']['delivery']['delivery_zone']['#options'][21]); // Hawaii unset($form['panes']['delivery']['delivery_zone']['#options'][49]); // Oregon unset($form['panes']['billing']['billing_zone']['#options'][21]); // Hawaii unset($form['panes']['billing']['billing_zone']['#options'][49]); // Oregon break; case 'uc_order_edit_form': // Disable some State/Province values in the order edit/create form unset($form['ship_to']['delivery_zone']['#options'][21]); // Hawaii unset($form['ship_to']['delivery_zone']['#options'][49]); // Oregon unset($form['bill_to']['billing_zone']['#options'][21]); // Hawaii unset($form['bill_to']['billing_zone']['#options'][49]); // Oregon break; } } |