original_string: protected function validateLimitCart()
      {
          if ($this->isError()) {
              return null;
          }
  
          $admin = $this->getSubmitted('admin');
          $product = $this->getSubmitted('product');
  
          if (!empty($admin) || empty($product)) {
              return null;
          }
  
          $sku = $this->getSubmitted('sku');
          $user_id = $this->getSubmitted('user_id');
          $store_id = $this->getSubmitted('store_id');
          $quantity = $this->getSubmitted('quantity');
          $increment = $this->getSubmitted('increment', true);
          $stock = $this->getSubmitted('stock', $product['stock']);
  
          $expected_quantity_sku = $quantity;
          $existing_quantity = $this->cart->getQuantity(array('user_id' => $user_id, 'store_id' => $store_id));
  
          if (!empty($increment) && isset($existing_quantity['sku'][$sku])) {
              $expected_quantity_sku += $existing_quantity['sku'][$sku];
          }
  
          if ($product['subtract'] && $expected_quantity_sku > $stock) {
              $error = $this->translation->text('Too low stock level');
              $this->setError('quantity', $error);
              return false;
          }
  
          $limit_sku = $this->cart->getLimits('sku');
          $limit_item = $this->cart->getLimits('item');
  
          if (!empty($limit_item) && !isset($existing_quantity['sku'][$sku]) && count($existing_quantity['sku']) >= $limit_item) {
              $error = $this->translation->text('Please no more than @num items', array('@num' => $limit_item));
              $this->setError('quantity', $error);
              return false;
          }
  
          if (!empty($limit_sku) && $expected_quantity_sku > $limit_sku) {
              $error = $this->translation->text('Please no more than @num items per SKU', array('@num' => $limit_sku));
              $this->setError('quantity', $error);
              return false;
          }
  
          return true;
      }
code: protected function validateLimitCart()
      {
          if ($this->isError()) {
              return null;
          }
  
          $admin = $this->getSubmitted('admin');
          $product = $this->getSubmitted('product');
  
          if (!empty($admin) || empty($product)) {
              return null;
          }
  
          $sku = $this->getSubmitted('sku');
          $user_id = $this->getSubmitted('user_id');
          $store_id = $this->getSubmitted('store_id');
          $quantity = $this->getSubmitted('quantity');
          $increment = $this->getSubmitted('increment', true);
          $stock = $this->getSubmitted('stock', $product['stock']);
  
          $expected_quantity_sku = $quantity;
          $existing_quantity = $this->cart->getQuantity(array('user_id' => $user_id, 'store_id' => $store_id));
  
          if (!empty($increment) && isset($existing_quantity['sku'][$sku])) {
              $expected_quantity_sku += $existing_quantity['sku'][$sku];
          }
  
          if ($product['subtract'] && $expected_quantity_sku > $stock) {
              $error = $this->translation->text('Too low stock level');
              $this->setError('quantity', $error);
              return false;
          }
  
          $limit_sku = $this->cart->getLimits('sku');
          $limit_item = $this->cart->getLimits('item');
  
          if (!empty($limit_item) && !isset($existing_quantity['sku'][$sku]) && count($existing_quantity['sku']) >= $limit_item) {
              $error = $this->translation->text('Please no more than @num items', array('@num' => $limit_item));
              $this->setError('quantity', $error);
              return false;
          }
  
          if (!empty($limit_sku) && $expected_quantity_sku > $limit_sku) {
              $error = $this->translation->text('Please no more than @num items per SKU', array('@num' => $limit_sku));
              $this->setError('quantity', $error);
              return false;
          }
  
          return true;
      }
code_tokens: protected function validateLimitCart ( ) { if ( $ this -> isError ( ) ) { return null ; } $ admin = $ this -> getSubmitted ( 'admin' ) ; $ product = $ this -> getSubmitted ( 'product' ) ; if ( ! empty ( $ admin ) || empty ( $ product ) ) { return null ; } $ sku = $ this -> getSubmitted ( 'sku' ) ; $ user_id = $ this -> getSubmitted ( 'user_id' ) ; $ store_id = $ this -> getSubmitted ( 'store_id' ) ; $ quantity = $ this -> getSubmitted ( 'quantity' ) ; $ increment = $ this -> getSubmitted ( 'increment' , true ) ; $ stock = $ this -> getSubmitted ( 'stock' , $ product [ 'stock' ] ) ; $ expected_quantity_sku = $ quantity ; $ existing_quantity = $ this -> cart -> getQuantity ( array ( 'user_id' => $ user_id , 'store_id' => $ store_id ) ) ; if ( ! empty ( $ increment ) && isset ( $ existing_quantity [ 'sku' ] [ $ sku ] ) ) { $ expected_quantity_sku += $ existing_quantity [ 'sku' ] [ $ sku ] ; } if ( $ product [ 'subtract' ] && $ expected_quantity_sku > $ stock ) { $ error = $ this -> translation -> text ( 'Too low stock level' ) ; $ this -> setError ( 'quantity' , $ error ) ; return false ; } $ limit_sku = $ this -> cart -> getLimits ( 'sku' ) ; $ limit_item = $ this -> cart -> getLimits ( 'item' ) ; if ( ! empty ( $ limit_item ) && ! isset ( $ existing_quantity [ 'sku' ] [ $ sku ] ) && count ( $ existing_quantity [ 'sku' ] ) >= $ limit_item ) { $ error = $ this -> translation -> text ( 'Please no more than @num items' , array ( '@num' => $ limit_item ) ) ; $ this -> setError ( 'quantity' , $ error ) ; return false ; } if ( ! empty ( $ limit_sku ) && $ expected_quantity_sku > $ limit_sku ) { $ error = $ this -> translation -> text ( 'Please no more than @num items per SKU' , array ( '@num' => $ limit_sku ) ) ; $ this -> setError ( 'quantity' , $ error ) ; return false ; } return true ; }
docstring: Validates cart limits
  @return boolean|null
docstring_tokens: Validates cart limits