/** * Validate a specific price */ private function validateSpecificPrice($id_product, $id_shop, $id_currency, $id_country, $id_group, $id_customer, $price, $from_quantity, $reduction, $reduction_type, $from, $to, $id_combination = 0) { if (!\Validate::isUnsignedId($id_shop) || !\ValidateCore::isUnsignedId($id_currency) || !\ValidateCore::isUnsignedId($id_country) || !\ValidateCore::isUnsignedId($id_group) || !\ValidateCore::isUnsignedId($id_customer)) { $this->errors[] = 'Wrong IDs'; } elseif (!isset($price) && !isset($reduction) || isset($price) && !\ValidateCore::isNegativePrice($price) || isset($reduction) && !\ValidateCore::isPrice($reduction)) { $this->errors[] = 'Invalid price/discount amount'; } elseif (!\ValidateCore::isUnsignedInt($from_quantity)) { $this->errors[] = 'Invalid quantity'; } elseif ($reduction && !\ValidateCore::isReductionType($reduction_type)) { $this->errors[] = 'Please select a discount type (amount or percentage).'; } elseif ($from && $to && (!\ValidateCore::isDateFormat($from) || !\ValidateCore::isDateFormat($to))) { $this->errors[] = 'The from/to date is invalid.'; } elseif (\SpecificPriceCore::exists((int) $id_product, $id_combination, $id_shop, $id_group, $id_country, $id_currency, $id_customer, $from_quantity, $from, $to, false)) { $this->errors[] = 'A specific price already exists for these parameters.'; } else { return true; } return false; }