**************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } fn_define('KEEP_UPLOADED_FILES', true); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $suffix = ''; if (!fn_allowed_for('ULTIMATE:FREE')) { if ($mode == 'add_exceptions') { foreach ($_REQUEST['add_options_combination'] as $k => $v) { $_data = array('product_id' => $_REQUEST['product_id'], 'combination' => $v); fn_update_exception($_data); } fn_recalculate_exceptions($_REQUEST['product_id']); $suffix = ".exceptions?product_id={$_REQUEST['product_id']}"; } if ($mode == 'm_delete_exceptions') { foreach ($_REQUEST['exception_ids'] as $id) { fn_delete_exception($id); } $suffix = ".exceptions?product_id={$_REQUEST['product_id']}"; } } if ($mode == 'add_combinations') { if (is_array($_REQUEST['add_inventory'])) { foreach ($_REQUEST['add_inventory'] as $k => $v) { $_data = array('product_id' => $_REQUEST['product_id'], 'combination' => $_REQUEST['add_options_combination'][$k], 'amount' => isset($_REQUEST['add_inventory'][$k]['amount']) ? $_REQUEST['add_inventory'][$k]['amount'] : 0);
public function update($id, $params) { $status = Response::STATUS_OK; $data = array(); $product_id = $this->safeGet($params, 'product_id', 0); if (empty($product_id)) { $product_id = db_get_field('SELECT product_id FROM ?:product_options WHERE option_id = ?i', $id); } list($_status, $message) = $this->checkProductId($product_id); if ($_status != Response::STATUS_OK) { return array('status' => $status, 'data' => array('message' => $message)); } $exception_id = fn_update_exception($params, $id); if ($exception_id) { $data = array('exception_id' => $exception_id); } else { $status = Response::STATUS_BAD_REQUEST; } return array('status' => $status, 'data' => $data); }