You are here

private function UcAjaxCart::checkKitToCart in Ubercart AJAX Cart 7.2

Same name and namespace in other branches
  1. 6.2 uc_ajax_cart.php \UcAjaxCart::checkKitToCart()
1 call to UcAjaxCart::checkKitToCart()
UcAjaxCart::addItemKitToCart in ./uc_ajax_cart.extender.inc

File

./uc_ajax_cart.extender.inc, line 62

Class

UcAjaxCart

Code

private function checkKitToCart($node, $data) {
  if (!module_exists('uc_attribute')) {
    return true;
  }
  $isValid = true;
  foreach ($data['products'] as $productData) {
    $product = node_load($productData['nid']);
    if ($this
      ->hasRequiredAttributes($product)) {
      foreach ($product->attributes as $attribute) {
        if ($attribute->required == "1" && (!isset($productData['attributes'][$attribute->aid]) || empty($productData['attributes'][$attribute->aid]))) {
          drupal_set_message(t('You must choose an option for !attribute in !product', array(
            '!attribute' => '<em>' . $attribute->name . '</em>',
            '!product' => '<strong>' . $product->title . '<strong>',
          )), 'error');
          $isValid = false;
        }
      }
    }
  }
  return $isValid;
}