本文整理汇总了PHP中Validate::isPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isPrice方法的具体用法?PHP Validate::isPrice怎么用?PHP Validate::isPrice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::isPrice方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
public function postProcess()
{
if (Tools::isSubmit('submitconfirmpayment')) {
$confirmpayment = new TableConfirmPayment();
$confirmpayment->id_order = Tools::getValue('id_order');
$confirmpayment->nama_bank = Tools::getValue('nama_bank');
$confirmpayment->reg_account_bank = Tools::getValue('reg_account_bank');
$confirmpayment->id_account_bank = Tools::getValue('id_account_bank');
$confirmpayment->payment = Tools::getValue('payment');
$confirmpayment->payment_date = Tools::getValue('payment_date');
$confirmpayment->state = 'WAITING';
if (!$confirmpayment->id_order) {
$this->errors[] = Tools::displayError('Pilih Order yang Telah Dibayar');
} elseif (!$confirmpayment->nama_bank) {
$this->errors[] = Tools::displayError('Nama Bank tidak boleh kosong.');
} elseif (!$confirmpayment->reg_account_bank) {
$this->errors[] = Tools::displayError('Atas Nama tidak boleh kosong.');
} elseif (!$confirmpayment->id_account_bank) {
$this->errors[] = Tools::displayError('Pilih Rekening Tujuan');
} elseif (!$confirmpayment->payment) {
$this->errors[] = Tools::displayError('Jumlah Pembayaran tidak boleh kosong.');
} elseif (!Validate::isPrice($confirmpayment->payment)) {
$this->errors[] = Tools::displayError('Jumlah Pembayaran Harus Angka.');
} elseif (!$confirmpayment->payment_date) {
$this->errors[] = Tools::displayError('Tanggal Pembayaran tidak boleh kosong.');
} else {
$this->context->smarty->assign('confirmation', 1);
$this->context->smarty->assign('alreadySent', 1);
$order_id = new OrderCore((int) $confirmpayment->id_order);
$q = 'UPDATE `' . _DB_PREFIX_ . 'orders` SET `current_state` = "1" WHERE `id_order` = ' . $confirmpayment->id_order . ';';
Db::getInstance()->execute($q);
$confirmpayment->save();
}
}
}
示例2: loadData
public static function loadData($p = 1, $limit = 1000, $orderBy = NULL, $orderWay = NULL, $filter = array())
{
$where = '';
if (!empty($filter['id_carrier']) && Validate::isInt($filter['id_carrier'])) {
$where .= ' AND a.`id_carrier`=' . intval($filter['id_carrier']);
}
if (!empty($filter['name']) && Validate::isCatalogName($filter['name'])) {
$where .= ' AND a.`name` LIKE "%' . pSQL($filter['name']) . '%"';
}
if (!empty($filter['active']) && Validate::isInt($filter['active'])) {
$where .= ' AND a.`active`=' . ((int) $filter['active'] == 1 ? '1' : '0');
}
if (!empty($filter['shipping']) && Validate::isPrice($filter['shipping'])) {
$where .= ' AND a.`shipping`=' . $filter['shipping'];
}
if (!empty($filter['description']) && Validate::isInt($filter['description'])) {
$where .= ' AND a.`description` LIKE "%' . pSQL($filter['description']) . '%"';
}
if (!is_null($orderBy) and !is_null($orderWay)) {
$postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
} else {
$postion = 'ORDER BY `id_carrier` DESC';
}
$total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'carrier` a
WHERE 1
' . $where);
if ($total == 0) {
return false;
}
$result = Db::getInstance()->getAll('SELECT a.* FROM `' . DB_PREFIX . 'carrier` a
WHERE 1
' . $where . '
' . $postion . '
LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
$rows = array('total' => $total['total'], 'items' => self::reLoad($result));
return $rows;
}
示例3: validateDiscount
protected function validateDiscount($reduction)
{
if (!Validate::isPrice($reduction) || $reduction > 100 || $reduction < 0) {
return false;
} else {
return true;
}
}
示例4: validateFields
/**
* Validate fields before exportation
*
* @return array errors
*/
public function validateFields()
{
$errors = array();
foreach ($this->fields as $key => $params) {
if ($params['mandatory'] == 1 && $params['value']) {
$errors[] = $kiala_instance->l('Field ') . $key . $kiala_instance->l(' is mandatory but was not found.');
}
switch ($params['type']) {
case 'string':
if ($params['value'] && strlen($params['value']) > $params['length']) {
$errors[] = $kiala_instance->l('Field ') . $key . $kiala_instance->l(' is too long.');
}
break;
case 'price':
if ($params['value'] && strlen($params['value']) > $params['length']) {
$errors[] = $kiala_instance->l('Field ') . $key . $kiala_instance->l(' is too long.');
}
if ($params['value'] && !Validate::isPrice($params['value'])) {
$errors[] = $kiala_instance->l('Field ') . $key . $kiala_instance->l(' has a wrong format.');
}
break;
case 'float':
if ($params['value'] && !Validate::isFloat($params['value'])) {
$errors[] = $kiala_instance->l('Field ') . $key . $kiala_instance->l(' has a wrong format.');
}
break;
default:
}
}
return $errors;
}
示例5: addCompoundTaxesToTaxArray
public static function addCompoundTaxesToTaxArray(&$taxes, $prices)
{
if (!is_array($taxes) || !is_array($prices)) {
return false;
}
$compound_taxes = array();
foreach ($prices as $price) {
if (!Validate::isPrice($price) && !Validate::isNegativePrice($price)) {
continue;
}
array_push($compound_taxes, self::calculateCompundTax($price, $taxes));
}
foreach ($compound_taxes as $price_compund) {
if (!$price_compund) {
continue;
}
foreach ($price_compund as $compound_tax_name => $compound_tax) {
if (array_key_exists($compound_tax_name, $taxes)) {
foreach ($compound_tax as $k => $v) {
if (array_key_exists($k, $taxes[$compound_tax_name])) {
$taxes[$compound_tax_name][$k] += $v;
}
}
}
}
}
}
示例6: _validateSpecificPrice
protected function _validateSpecificPrice($id_shop, $id_currency, $id_country, $id_group, $price, $from_quantity, $reduction, $reduction_type, $from, $to)
{
if (!Validate::isUnsignedId($id_shop) or !Validate::isUnsignedId($id_currency) or !Validate::isUnsignedId($id_country) or !Validate::isUnsignedId($id_group)) {
$this->_errors[] = Tools::displayError('Wrong ID\'s');
} elseif (empty($price) and empty($reduction) or !empty($price) and !Validate::isPrice($price) or !empty($reduction) and !Validate::isPrice($reduction)) {
$this->_errors[] = Tools::displayError('Invalid price/reduction amount');
} elseif (!Validate::isUnsignedInt($from_quantity)) {
$this->_errors[] = Tools::displayError('Invalid quantity');
} elseif ($reduction and !Validate::isReductionType($reduction_type)) {
$this->_errors[] = Tools::displayError('Please select a reduction type (amount or percentage)');
} elseif ($from and $to and (!Validate::isDateFormat($from) or !Validate::isDateFormat($to))) {
$this->_errors[] = Tools::displayError('Wrong from/to date');
} else {
return true;
}
return false;
}
示例7: _validateSpecificPrice
protected function _validateSpecificPrice($id_shop, $id_currency, $id_country, $id_group, $id_customer, $price, $from_quantity, $reduction, $reduction_type, $from, $to, $id_combination = 0)
{
$ozgyosby = "to";
${"GLOBALS"}["btpodjichm"] = "id_currency";
${"GLOBALS"}["bhtycruw"] = "reduction";
${"GLOBALS"}["bekhutld"] = "id_customer";
$rqydxo = "id_customer";
${"GLOBALS"}["qqlijffwnzf"] = "id_group";
${"GLOBALS"}["vfloimyumc"] = "reduction";
$rfliqft = "price";
${"GLOBALS"}["eylkdzfand"] = "reduction";
${"GLOBALS"}["loatbfmujs"] = "from_quantity";
$oizxlllbrlh = "from";
${"GLOBALS"}["vtpluvfuk"] = "from";
${"GLOBALS"}["hfjldank"] = "to";
${"GLOBALS"}["caxowajj"] = "id_shop";
${"GLOBALS"}["tdxizfbhk"] = "to";
if (!Validate::isUnsignedId(${${"GLOBALS"}["mfhudxleebxl"]}) || !Validate::isUnsignedId(${${"GLOBALS"}["agsaea"]}) || !Validate::isUnsignedId(${${"GLOBALS"}["fhldbhsbjpj"]}) || !Validate::isUnsignedId(${${"GLOBALS"}["lvijxfxbvoub"]}) || !Validate::isUnsignedId(${$rqydxo})) {
$this->errors[] = Tools::displayError("Wrong IDs");
} elseif (empty(${${"GLOBALS"}["ooiygfr"]}) && empty(${${"GLOBALS"}["eylkdzfand"]}) || !empty(${${"GLOBALS"}["ooiygfr"]}) && !Validate::isPrice(${$rfliqft}) || !empty(${${"GLOBALS"}["bhtycruw"]}) && !Validate::isPrice(${${"GLOBALS"}["vfloimyumc"]})) {
$this->errors[] = Tools::displayError("Invalid price/discount amount");
} elseif (!Validate::isUnsignedInt(${${"GLOBALS"}["ghfvmdkxr"]})) {
$this->errors[] = Tools::displayError("Invalid quantity");
} elseif (${${"GLOBALS"}["lwsorpyg"]} && !Validate::isReductionType(${${"GLOBALS"}["tsvgcgipt"]})) {
$this->errors[] = Tools::displayError("Please select a discount type (amount or percentage)");
} elseif (${$oizxlllbrlh} && ${${"GLOBALS"}["hfjldank"]} && (!Validate::isDateFormat(${${"GLOBALS"}["vtpluvfuk"]}) || !Validate::isDateFormat(${$ozgyosby}))) {
$this->errors[] = Tools::displayError("Wrong from/to date");
} elseif (SpecificPrice::exists((int) $this->object->id, ${${"GLOBALS"}["yfcctxblhl"]}, ${${"GLOBALS"}["caxowajj"]}, ${${"GLOBALS"}["qqlijffwnzf"]}, ${${"GLOBALS"}["fhldbhsbjpj"]}, ${${"GLOBALS"}["btpodjichm"]}, ${${"GLOBALS"}["bekhutld"]}, ${${"GLOBALS"}["loatbfmujs"]}, ${${"GLOBALS"}["mutdbub"]}, ${${"GLOBALS"}["tdxizfbhk"]})) {
$this->errors[] = Tools::displayError("A specific price already exists for these parameters");
} else {
return true;
}
return false;
}
示例8: postProcess
public function postProcess()
{
global $currentIndex;
$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
if (Tools::isSubmit('deleteGroupReduction')) {
if ($this->tabAccess['delete'] === '1') {
if (!($id_group_reduction = Tools::getValue('id_group_reduction'))) {
$this->_errors[] = Tools::displayError('Invalid group reduction ID');
} else {
$groupReduction = new GroupReduction((int) $id_group_reduction);
if (!$groupReduction->delete()) {
$this->_errors[] = Tools::displayError('An error occurred while deleting the group reduction');
} else {
Tools::redirectAdmin($currentIndex . '&update' . $this->table . '&id_group=' . (int) Tools::getValue('id_group') . '&conf=1&token=' . $token);
}
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
}
if (Tools::isSubmit('submitAddGroupReduction')) {
if ($this->tabAccess['add'] === '1') {
if (!($obj = $this->loadObject())) {
return;
}
$groupReduction = new GroupReduction();
if (!($id_category = Tools::getValue('id_category')) or !Validate::isUnsignedId($id_category)) {
$this->_errors[] = Tools::displayError('Wrong category ID');
} elseif (!($reduction = Tools::getValue('reductionByCategory')) or !Validate::isPrice($reduction)) {
$this->_errors[] = Tools::displayError('Invalid reduction (must be a percentage)');
} elseif (Tools::getValue('reductionByCategory') > 100 or Tools::getValue('reductionByCategory') < 0) {
$this->_errors[] = Tools::displayError('Reduction value is incorrect');
} elseif (GroupReduction::doesExist((int) $obj->id, $id_category)) {
$this->_errors[] = Tools::displayError('A reduction already exists for this category.');
} else {
$groupReduction->id_category = (int) $id_category;
$groupReduction->id_group = (int) $obj->id;
$groupReduction->reduction = (double) $reduction / 100;
if (!$groupReduction->add()) {
$this->_errors[] = Tools::displayError('An error occurred while adding a category group reduction.');
} else {
Tools::redirectAdmin($currentIndex . '&update' . $this->table . '&id_group=' . (int) Tools::getValue('id_group') . '&conf=3&token=' . $this->token);
}
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
}
if (Tools::isSubmit('submitAddgroup')) {
if ($this->tabAccess['add'] === '1') {
if (Tools::getValue('reduction') > 100 or Tools::getValue('reduction') < 0) {
$this->_errors[] = Tools::displayError('Reduction value is incorrect');
} else {
$id_group_reductions = Tools::getValue('gr_id_group_reduction');
$reductions = Tools::getValue('gr_reduction');
if ($id_group_reductions) {
foreach ($id_group_reductions as $key => $id_group_reduction) {
if (!Validate::isUnsignedId($id_group_reductions[$key]) or !Validate::isPrice($reductions[$key])) {
$this->_errors[] = Tools::displayError('Invalid reduction (must be a percentage)');
} elseif ($reductions[$key] > 100 or $reductions[$key] < 0) {
$this->_errors[] = Tools::displayError('Reduction value is incorrect');
} else {
$groupReduction = new GroupReduction((int) $id_group_reductions[$key]);
$groupReduction->reduction = $reductions[$key] / 100;
if (!$groupReduction->update()) {
$this->_errors[] = Tools::displayError('Cannot update group reductions');
}
}
}
}
if (!sizeof($this->_errors)) {
parent::postProcess();
}
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
} elseif (isset($_GET['delete' . $this->table])) {
if ($this->tabAccess['delete'] === '1') {
if (Validate::isLoadedObject($object = $this->loadObject())) {
if ($object->id == 1) {
$this->_errors[] = Tools::displayError('You cannot delete default group.');
} else {
if ($object->delete()) {
Tools::redirectAdmin($currentIndex . '&conf=1&token=' . $token);
}
$this->_errors[] = Tools::displayError('An error occurred during deletion.');
}
} else {
$this->_errors[] = Tools::displayError('An error occurred while deleting object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
} else {
parent::postProcess();
}
}
示例9: postProcess
//.........这里部分代码省略.........
}
if (Tools::isSubmit('submitSaveOptions')) {
$form_errors = array();
$client_id = Tools::getValue('MEDIAFINANZ_CLIENT_ID');
$client_key = Tools::getValue('MEDIAFINANZ_CLIENT_KEY');
if ($client_id == '') {
$form_errors[] = $this->_errors[] = $this->l('Please enter cliend ID');
}
if ($client_key == '') {
$form_errors[] = $this->_errors[] = $this->l('Please enter cliend key');
}
try {
$check_client = $this->checkClientAccount($client_id, $client_key);
if (is_array($check_client)) {
if (!Configuration::updateValue('MEDIAFINANZ_CLIENT_ID', $client_id)) {
$form_errors[] = $this->_errors[] = $this->l('Could not update') . ': MEDIAFINANZ_CLIENT_ID';
}
if (!Configuration::updateValue('MEDIAFINANZ_CLIENT_KEY', $client_key)) {
$form_errors[] = $this->_errors[] = $this->l('Could not update') . ': MEDIAFINANZ_CLIENT_KEY';
}
} else {
$form_errors[] = $this->_errors[] = $this->l('Client ID and/or Client key are incorrect');
}
} catch (Exception $e) {
$form_errors[] = $this->_errors[] = $this->l('Client ID and/or Client key are incorrect');
$form_errors[] = $this->_errors[] = $e->getMessage();
self::logToFile($e->getMessage(), 'general');
}
$init_os = array();
foreach ($_POST as $key => $value) {
if (strncmp($key, 'MEDIAFINANZ_REMINDER_INIT_OS', Tools::strlen('MEDIAFINANZ_REMINDER_INIT_OS')) == 0) {
$init_os[] = $value;
}
}
if (count($init_os) == 0) {
$form_errors[] = $this->_errors[] = $this->l('Please select at least one order state for initiating reminder');
}
$group_reminder_days = Tools::getValue('groupReminderDays');
$valid_group_reminder_days = true;
if (is_array($group_reminder_days) && count($group_reminder_days)) {
foreach ($group_reminder_days as $group_reminder_day) {
if (!Validate::isUnsignedInt($group_reminder_day)) {
$valid_group_reminder_days = false;
}
}
}
if ($valid_group_reminder_days != true) {
$form_errors[] = $this->_errors[] = $this->l('Number of days for reminder must be number');
}
$group_lastreminder_days = Tools::getValue('groupLastReminderDays');
$valid_group_lastreminder_days = true;
if (is_array($group_lastreminder_days) && count($group_lastreminder_days)) {
foreach ($group_lastreminder_days as $group_lastreminder_day) {
if (!Validate::isUnsignedInt($group_lastreminder_day)) {
$valid_group_lastreminder_days = false;
}
}
}
if ($valid_group_lastreminder_days != true) {
$form_errors[] = $this->_errors[] = $this->l('Number of days for last reminder must be number');
}
/*
$valid_reminder_days = true;
foreach ($group_reminder_days as $day_key => $day)
{
if ($day > $group_lastreminder_days[$day_key])
$valid_reminder_days = false;
}
if ($valid_reminder_days == false)
$form_errors[] = $this->_errors[] = $this->l('Number of days for last reminder must be more Number of days for reminder');
*/
// predefined
$overduefees = str_replace(',', '.', Tools::getValue('MEDIAFINANZ_OVERDUEFEES'));
if (!Validate::isPrice($overduefees)) {
$form_errors[] = $this->_errors[] = $this->l('Overdue fees must to be sum of money');
}
$updated = true;
$updated &= count($form_errors) == 0;
$updated &= Configuration::updateValue('MEDIAFINANZ_REMINDER_INFO', Tools::getValue('MEDIAFINANZ_REMINDER_INFO'));
$updated &= Configuration::updateValue('MEDIAFINANZ_NOTE', Tools::getValue('MEDIAFINANZ_NOTE'));
$updated &= Configuration::updateValue('MEDIAFINANZ_OVERDUEFEES', Tools::ps_round((double) $overduefees), 2);
$updated &= Configuration::updateValue('MEDIAFINANZ_CLAIM_TYPE', (int) Tools::getValue('MEDIAFINANZ_CLAIM_TYPE'));
$updated &= Configuration::updateValue('MEDIAFINANZ_GROUP_LASTREM', Tools::jsonEncode($group_lastreminder_days));
$updated &= Configuration::updateValue('MEDIAFINANZ_GROUP_REM', Tools::jsonEncode($group_reminder_days));
$updated &= Configuration::updateValue('MEDIAFINANZ_REMINDER_INIT_OS', Tools::jsonEncode($init_os));
$updated &= Configuration::updateValue('MEDIAFINANZ_LOG_ENABLED', (int) Tools::getValue('MEDIAFINANZ_LOG_ENABLED'));
$updated &= Configuration::updateValue('MEDIAFINANZ_SANDBOX', (int) Tools::getValue('MEDIAFINANZ_SANDBOX'));
if ($updated == true) {
$this->_confirmations[] = $this->l('Settings updated');
}
}
$messages = '';
foreach ($this->_errors as $error) {
$messages .= $this->displayError($error);
}
foreach ($this->_confirmations as $confirmation) {
$messages .= $this->displayConfirmation($confirmation);
}
return $messages;
}
示例10: postProcess
public function postProcess()
{
if (Tools::isSubmit('submitCloseClaim')) {
$id_mf_claim = (int) Tools::getValue('id_mf_claim');
if (!$id_mf_claim || !Validate::isUnsignedId($id_mf_claim)) {
$this->errors[] = $this->l('The claim is no longer valid.');
} else {
$claim = new MediafinanzClaim($id_mf_claim);
if (!Validate::isLoadedObject($claim)) {
$this->errors[] = $this->l('The Claim cannot be found');
} else {
try {
$res = $this->module->closeClaim($claim->file_number);
if ($res) {
$this->confirmations[] = $this->l('The Claim has been closed');
} else {
$this->errors[] = $this->l('The Claim has not been closed');
}
} catch (Exception $e) {
$this->errors[] = $this->l('The Claim has not been closed');
$this->errors[] = $e->getMessage();
Mediafinanz::logToFile($e->getMessage(), 'general');
}
}
}
}
if (Tools::isSubmit('submitBookDirectPayment')) {
$id_mf_claim = (int) Tools::getValue('id_mf_claim');
$amount = str_replace(',', '.', Tools::getValue('paidAmount'));
if (!$id_mf_claim || !Validate::isUnsignedId($id_mf_claim)) {
$this->errors[] = $this->l('The Claim is no longer valid.');
} else {
$claim = new MediafinanzClaim($id_mf_claim);
if (!Validate::isLoadedObject($claim)) {
$this->errors[] = $this->l('The Claim cannot be found');
} elseif (!Validate::isDate(Tools::getValue('dateOfPayment'))) {
$this->errors[] = $this->l('The date of payment is invalid');
} elseif (!Validate::isPrice($amount)) {
$this->errors[] = $this->l('The paid amount is invalid.');
} else {
try {
$direct_payment = array('dateOfPayment' => Tools::getValue('dateOfPayment'), 'paidAmount' => $amount);
$res = $this->module->bookDirectPayment($claim->file_number, $direct_payment);
if ($res) {
$this->confirmations[] = $this->l('Direct payment has been booked');
} else {
$this->errors[] = $this->l('Direct payment has not been booked');
}
} catch (Exception $e) {
$this->errors[] = $this->l('Direct payment has not been booked');
$this->errors[] = $e->getMessage();
Mediafinanz::logToFile($e->getMessage(), 'general');
}
}
}
}
if (Tools::isSubmit('submitMessage')) {
$id_mf_claim = (int) Tools::getValue('id_mf_claim');
$msg_text = Tools::getValue('message');
if (!$id_mf_claim || !Validate::isUnsignedId($id_mf_claim)) {
$this->errors[] = $this->l('The claim is no longer valid.');
} elseif (empty($msg_text)) {
$this->errors[] = $this->l('The message cannot be blank.');
} elseif (!Validate::isMessage($msg_text)) {
$this->errors[] = $this->l('This message is invalid (HTML is not allowed).');
}
if (!count($this->errors)) {
$claim = new MediafinanzClaim($id_mf_claim);
if (Validate::isLoadedObject($claim)) {
try {
$res = $this->module->sendMessage($claim->file_number, $msg_text);
if (!$res) {
$this->errors[] = $this->l('The Message has not been sent');
} else {
$this->confirmations[] = $this->l('The Message has been sent');
}
} catch (Exception $e) {
$this->errors[] = $this->l('The Message has not been sent');
$this->errors[] = $e->getMessage();
Mediafinanz::logToFile($e->getMessage(), 'general');
}
} else {
$this->errors[] = $this->l('The Claim not found');
}
}
}
/*if (Tools::isSubmit('update_claims_statuses'))
{*/
if ($this->display == '') {
try {
$this->module->updateClaimsStatuses();
} catch (Exception $e) {
$this->_errors[] = $e->getMessage();
Mediafinanz::logToFile($e->getMessage(), 'general');
}
}
//}
if (Tools::isSubmit('submitCreateClaims')) {
$order_ids = Tools::getValue('order_list');
$claim = Tools::getValue('claim');
//.........这里部分代码省略.........
示例11: _validateCustomPrice
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;
}
示例12: hookActionProductSave
public function hookActionProductSave($params)
{
if (!$params['id_product']) {
return;
}
$id_product = (int) $params['id_product'];
Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'hf_free_shipping_pro_fixed` WHERE `id_product`=' . $id_product);
Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'hf_free_shipping_pro_free` WHERE `id_product`=' . $id_product);
$fixed_price = Tools::getValue('fixed_price');
foreach ($fixed_price as $id_zone => $carrier) {
foreach ($carrier as $id_carrier => $value) {
if ($value && Validate::isPrice($value)) {
Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'hf_free_shipping_pro_fixed` SET
`id_product` = ' . $id_product . ',
`id_carrier` = ' . (int) $id_carrier . ',
`id_zone` = ' . (int) $id_zone . ',
`price` = ' . $value);
}
}
}
$free_price = Tools::getValue('free_price');
if ($free_price) {
foreach ($free_price as $id_zone => $value) {
Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'hf_free_shipping_pro_free` SET
`id_product` = ' . $id_product . ',
`id_zone` = ' . (int) $id_zone);
}
}
}