You are here

function uc_shipping_new_package_validate in Ubercart 7.3

Same name and namespace in other branches
  1. 5 shipping/uc_shipping/uc_shipping.module \uc_shipping_new_package_validate()
  2. 6.2 shipping/uc_shipping/uc_shipping.admin.inc \uc_shipping_new_package_validate()

Validation handler for uc_shipping_new_package().

Do not allow empty packages.

See also

uc_shipping_new_package()

uc_shipping_new_package_submit()

File

shipping/uc_shipping/uc_shipping.admin.inc, line 230
Shipping administration menu items.

Code

function uc_shipping_new_package_validate($form, &$form_state) {
  if ($form_state['values']['op'] != t('Cancel')) {
    $empty = TRUE;
    foreach ($form_state['values']['shipping_types'] as $shipping_type => $products) {
      foreach ($products as $product) {
        if ($product['checked'] != 0) {
          $empty = FALSE;
          break 2;
        }
      }
    }
    if ($empty) {
      form_set_error($shipping_type, t('Packages should have at least one product in them.'));
    }
  }
}