You are here

function uc_shipping_new_package_validate in Ubercart 5

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

Validation handler for uc_shipping_new_package().

Do not allow empty packages.

File

shipping/uc_shipping/uc_shipping.module, line 327
Organizes ordered products into packages and sets them up for shipment. Shipping method modules may add functionality to generate shipping labels and tracking numbers.

Code

function uc_shipping_new_package_validate($form_id, $form_values) {
  if ($form_values['op'] != t('Cancel')) {
    $empty = true;
    foreach ($form_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.'));
    }
  }
}