original_string: public function addToProductCompare($compare_action_model)
      {
          $errors = $this->error();
  
          if (empty($errors)) {
              $submitted = $this->getSubmitted();
              $result = $compare_action_model->add($submitted['product'], $submitted);
          } else {
              $result = array(
                  'redirect' => '',
                  'severity' => 'warning',
                  'message' => $this->format($errors)
              );
          }
  
          if ($this->isAjax()) {
              $this->outputJson($result);
          }
  
          $this->redirect($result['redirect'], $result['message'], $result['severity']);
      }
code: public function addToProductCompare($compare_action_model)
      {
          $errors = $this->error();
  
          if (empty($errors)) {
              $submitted = $this->getSubmitted();
              $result = $compare_action_model->add($submitted['product'], $submitted);
          } else {
              $result = array(
                  'redirect' => '',
                  'severity' => 'warning',
                  'message' => $this->format($errors)
              );
          }
  
          if ($this->isAjax()) {
              $this->outputJson($result);
          }
  
          $this->redirect($result['redirect'], $result['message'], $result['severity']);
      }
code_tokens: public function addToProductCompare ( $ compare_action_model ) { $ errors = $ this -> error ( ) ; if ( empty ( $ errors ) ) { $ submitted = $ this -> getSubmitted ( ) ; $ result = $ compare_action_model -> add ( $ submitted [ 'product' ] , $ submitted ) ; } else { $ result = array ( 'redirect' => '' , 'severity' => 'warning' , 'message' => $ this -> format ( $ errors ) ) ; } if ( $ this -> isAjax ( ) ) { $ this -> outputJson ( $ result ) ; } $ this -> redirect ( $ result [ 'redirect' ] , $ result [ 'message' ] , $ result [ 'severity' ] ) ; }
docstring: Adds a submitted product to comparison
  @param \gplcart\core\models\ProductCompareAction $compare_action_model
docstring_tokens: Adds a submitted product to comparison