Explore the advanced validation rules

Explore the advanced validation rules

You can use two different ways to check field errors using PHP (For example you can add validation to check if Field1 < 100 and Field2 < 100)  This example code will work for WPC >= 2.3.0.  You can add this code by installing Code Snippets Plugin  function custom_awspc_filter_calculate_price_errors($errors, $params){    $calculator= $params[‘calculator’];     $userData= $params[‘userData‘];       /* Applying rule to calculator with ID 6 (Get the ID from the Edit page of the calculator in the URL bar) */     if($calculator->id == 6){       /* Check if Field 1 > 100 && Field 2 > 100 */     if($userData[‘aws_price_calc_1’] > 100 && $userData[‘aws_price_calc_2’] > 100){      /* Display the error */   $errorMessage= “Field1 must be < 100 and Field2 must be < 100”;      $errors[‘aws_price_calc_1‘][]= $errorMessage;   $errors[‘aws_price_calc_2‘][]= $errorMessage;        }        }        return $errors;  }    add_filter(awspc_filter_calculate_price_errors“, “custom_awspc_filter_calculate_price_errors“, 10, 2);  $params is a PHP array with the following: 
  • $params[‘priceRaw‘]: The result price without formatting 
  • $params[‘product’]: The product 
  • $params[‘calculator’]: The calculator 
  • $params[‘data’]: The user data (Some values could contain ID instead of real user values) 
  • $params[‘userData‘]: The user data without any transformation 
  • $params[‘outputResults‘]: The output fields