Exemple #1
0
 public function buildAddToCartValidator($options, $variations, $prefix = '')
 {
     $validator = $this->getValidator("addToCart", $this->getRequest());
     $prefixes = (array) $prefix;
     // option validation
     foreach ($prefixes as $prefix) {
         foreach ($options as $option) {
             if ($option['isRequired']) {
                 $optField = $prefix . 'option_' . $option['ID'];
                 OrderController::addOptionValidation($validator, $option, $optField);
             }
         }
         if (isset($variations['variations'])) {
             foreach ($variations['variations'] as $variation) {
                 $validator->addCheck($prefix . 'variation_' . $variation['ID'], new IsNotEmptyCheck($this->translate('_err_option_0')));
             }
         }
         $validator->addCheck($prefix . 'count', new IsNumericCheck(''));
         $validator->addFilter($prefix . 'count', new NumericFilter());
     }
     return $validator;
 }