/** * Updates a customer product option. * * @param int $customer_id Customer ID. * @param int $id Customer product option to cancel. * @param array $data Data to update. * * @return void */ protected function update($customer_id, $id, array $data) { $customer = $this->get_customer($customer_id); $option = $this->get_option($id); if (!Service_Customer_Product_Option::update($option, $data)) { Session::set_alert('error', 'There was an error updating the customer product.'); } else { Session::set_alert('success', 'The customer product has been updated.'); } Response::redirect($customer->link('products')); }
/** * Switches the active seller. * * @param int $id Seller ID. * * @return void */ public function action_switch($id = null) { if (!$id) { throw new HttpNotFoundException(); } $seller = Service_Seller::find_one($id); if (!$seller) { throw new HttpNotFoundException(); } Seller::set($seller); Session::set_alert('success', "You are now viewing as seller \"{$seller->name}\"."); Response::redirect('/'); }
/** * Deletes a seller API key. * * @param int $id API key. * * @return void */ public function action_delete($id = null) { if (!$id) { throw new HttpNotFoundException(); } $key = Service_Api_Key::find_one($id); if (!$key || $key->seller != Seller::active()) { throw new HttpNotFoundException(); } if (!Service_Api_Key::delete($key)) { Session::set_alert('error', 'There was an error removing the API key.'); } else { Session::set_alert('success', 'The API key has been removed.'); } Response::redirect('settings/api'); }
/** * POST Index action. * * @return void */ public function post_index() { $this->get_index(); $validator = Validation_Seller::create(); if (!$validator->run()) { Session::set_alert('error', __('form.error')); $this->view->errors = $validator->error(); return; } $data = $validator->validated(); if (!($seller = Service_Seller::create($data['name'], $data))) { Session::set_alert('error', 'There was an error adding the seller.'); return; } Response::redirect($seller->link('switch')); }
/** * POST Edit action. * * @param int $id Product ID. * * @return void */ public function post_edit($id = null) { $this->get_edit($id); $validator = Validation_Product::update(); if (!$validator->run()) { Session::set_alert('error', __('form.error')); $this->view->errors = $validator->error(); return; } $product = $this->get_product($id); $data = $validator->validated(); if (!Service_Product::update($product, $data)) { Session::set_alert('error', 'There was an error updating the product.'); return; } Session::set_alert('success', 'The product has been updated.'); Response::redirect($product->link('edit')); }
/** * POST Edit action. * * @param int $customer_id Customer ID. * @param int $id Contact ID. * * @return void */ public function post_edit($customer_id = null, $id = null) { $this->get_edit($customer_id, $id); $validator = Validation_Contact::update(); if (!$validator->run()) { Session::set_alert('error', __('form.error')); $this->view->errors = $validator->error(); return; } $customer = $this->get_customer($customer_id); $contact = $this->get_contact($customer_id, $id); $data = $validator->validated(); if (!Service_Contact::update($contact, $data)) { Session::set_alert('error', 'There was an error updating the customer contact.'); return; } Session::set_alert('success', 'The customer contact has been updated.'); Response::redirect($customer->link('contacts')); }
/** * Validates meta option data for a given action type. * * @param string $type The action to process (create, update). * @param array $data The data to validate. * * @return array|bool */ protected function validate_meta_option($type, $data) { if ($type == 'create') { $validator = Validation_Product_Meta_Option::create(); } else { $validator = Validation_Product_Meta_Option::update(); } if (!$validator->run($data)) { Session::set_alert('error', __('form.error')); $this->view->errors = $validator->error(); return; } return $validator->validated(); }
/** * Delete action. * * @param int $customer_id Customer ID. * @param int $id Payment method ID. * * @return void */ public function action_delete($customer_id = null, $id = null) { if (!Service_Customer_Paymentmethod::delete($this->get_paymentmethod($id))) { Session::set_alert('error', 'There was an error removing the customer payment method.'); } else { Session::set_alert('success', 'The customer payment method has been removed.'); } Response::redirect($this->get_customer($customer_id)->link('paymentmethods')); }
/** * Deletes a seller callback. * * @param int $seller_id Seller ID. * @param int $id Seller callback ID. * * @return void */ public function action_delete($id = null) { $callback = $this->get_callback($id); if (!Service_Seller_Callback::delete($callback)) { Session::set_alert('error', 'There was an error deleting the event callback.'); } else { Session::set_alert('success', 'The event callback has been deleted.'); } Response::redirect(Seller::active()->link('callbacks')); }
/** * POST Edit action. * * @param int $option_id Product option ID. * @param int $id Product option fee ID. * * @return void */ public function post_edit($option_id = null, $id = null) { $this->get_edit($option_id, $id); $validator = Validation_Product_Option_Fee::update(); if (!$validator->run()) { Session::set_alert('error', __('form.error')); $this->view->errors = $validator->error(); return; } $option = $this->get_option($option_id); $fee = $this->get_fee($id); $data = $validator->validated(); if (!Service_Product_Option_Fee::update($fee, $data)) { Session::set_alert('error', 'There was an error updating the product option fee.'); return; } Session::set_alert('success', 'The product option fee has been updated.'); Response::redirect($option->link('fees')); }
/** * POST Edit action. * * @param int $id Gateway ID. * * @return void */ public function post_edit($id = null) { $this->get_edit($id); $validator = Validation_Gateway::update(); if (!$validator->run()) { Session::set_alert('error', __('form.error')); $this->view->errors = $validator->error(); return; } $data = $validator->validated(); if (!Service_Gateway::update($this->get_gateway($id), $data)) { Session::set_alert('error', 'There was an error updating the gateway.'); } else { Session::set_alert('success', 'The gateway has been updated.'); } Response::redirect('settings/gateways'); }