Make phone field required if certain shipping method is selected
You will have two functions in your custom module. The first one is hook_form_FORM_ID_alter:

/**
 * This function adds an additional custom validation function to the delivery phone field
 *
 * Make sure you update MYMODULE and YOURFORMID to match your circumstances.
 */
function MYMODULE_form_YOURFORMID_alter(&amp;$form, &amp;$form_state) {
  $form['panes']['delivery']['delivery_phone']['#element_validate'] = array('MYMODULE_phone_validate');
}


The second function is the custom validation function that we added using hook_form_FORM_ID_alter above:

/**
 * Make sure you update MYMODULE again and update the array to match your shipping method
 */
function MYMODULE_phone_validate($element, &amp;$form_state) {
  if (($form_state['panes']['shipping']['shipping_method']['#value'] == 'THE SHIPPING METHOD') &amp;&amp; ($element['#value'] == '')) {
    form_error($element, t('You must enter a phone number if you select XXX as a shipping method.'));
  }
}