AdamalX2 Posted September 23, 2015 Share Posted September 23, 2015 Sorry if this has been asked before. I couldn't find it by searching google or the forums. Is there a way to install an order status on install of a payment module? Where can I find documentation or example code. Also when creating a custom order status can you specify a custom email template within the module? Thanks In advance. Link to comment Share on other sites More sharing options...
yaniv14 Posted September 24, 2015 Share Posted September 24, 2015 You can add a custom function in your module to add the order state and call it with the install function. public function install() { ......... $this->addOrderState($this->l('Name of new state')) && ..........} public function addOrderState($name) { $state_exist = false; $states = OrderState::getOrderStates((int)$this->context->language->id); // check if order state exist foreach ($states as $state) { if (in_array($name, $state)) { $state_exist = true; break; } } // If the state does not exist, we create it. if (!$state_exist) { // create new order state $order_state = new OrderState(); $order_state->color = '#00ffff'; $order_state->send_email = true; $order_state->module_name = 'name if your module'; $order_state->template = 'name of your email template'; $order_state->name = array(); $languages = Language::getLanguages(false); foreach ($languages as $language) $order_state->name[ $language['id_lang'] ] = $name; // Update object $order_state->add(); } return true; } I think it should work. 1 Link to comment Share on other sites More sharing options...
AdamalX2 Posted September 24, 2015 Author Share Posted September 24, 2015 Thanks, I'll give that a shot tonight. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now