Ejemplo n.º 1
0
 public function delete()
 {
     if (parent::delete()) {
         // Flush cache when we deletind a new custom price
         $this->flushCache();
         // Refresh cache of feature detachable
         Configuration::updateGlobalValue('PS_SPECIFIC_PRICE_FEATURE_ACTIVE', CustomPrice::isCurrentlyUsed($this->def['table']));
         return true;
     }
     return false;
 }
 protected function _validateCustomPrice($id_shop, $id_product, $id_currency, $id_country, $id_group, $id_customer, $price, $from_quantity, $reduction, $reduction_type, $from, $to, $id_combination = 0)
 {
     if (!Validate::isUnsignedId($id_shop) || !Validate::isUnsignedId($id_currency)) {
         //$this->errors[] = Tools::displayError('Wrong IDs');
         //error_log(__LINE__);
         return false;
     } elseif (!isset($price) && !isset($reduction) || isset($price) && !Validate::isNegativePrice($price) || isset($reduction) && !Validate::isPrice($reduction)) {
         //$this->errors[] = Tools::displayError('Invalid price/discount amount');
         //error_log(__LINE__);
         return false;
     } elseif ($reduction && !Validate::isReductionType($reduction_type)) {
         //$this->errors[] = Tools::displayError('Please select a discount type (amount or percentage).');
         //error_log(__LINE__);
         return false;
     } elseif ($from && $to && (!Validate::isDateFormat($from) || !Validate::isDateFormat($to))) {
         //$this->errors[] = Tools::displayError('The from/to date is invalid.');
         //error_log(__LINE__);
         return false;
     } elseif (empty($this->id) && CustomPrice::exists($id_product, $id_combination, $id_shop, $id_group, $id_country, $id_currency, $id_customer, $from_quantity, $from, $to, false)) {
         //$this->errors[] = Tools::displayError('A custom price already exists for these parameters.');
         //error_log(__LINE__);
         return false;
     } else {
         //error_log(__LINE__);
         return false;
     }
     return false;
 }