omine Posted March 27, 2015 Share Posted March 27, 2015 (edited) I'm developing a module. I couldn't found on documentation or forums about how to set email template for each order status and languages available. Example I have the following order statuses: 1. processing 2. canceled 3. error 4. accepted I have about 4 languages 1. pt 2. ja 3. es 4. en I want set programmatically, from module installer, all statuses and its mail templates Sample: $states = array( 'MODULE_OS_ACCEPTED' => array( 'label'=>'Transaction accepted', 'icon'=> 'module_os_accepted', 'send_email'=>true, 'color'=>'#DDEEFF', 'hidden'=>false, 'delivery'=>false, 'logable'=>true, 'invoice'=>true, ), 'MODULE_OS_PROCESSING' => array( 'label'=>'Transaction in process', 'icon'=>'module_os_processing', 'send_email'=>false, 'color'=>'#FFCC66', 'hidden'=>false, 'delivery'=>false, 'logable'=>true, 'invoice'=>false, ), ); foreach( $states as $k => $v ) { if (!Configuration::get($k)) { $order_state = new OrderState(); $order_state->name = array(); foreach (Language::getLanguages() as $language) { $order_state->name[$language['id_lang']] = $v['label'] . ' ('.$this->displayName.')'; } $order_state->send_email = $v['send_email']; $order_state->color = $v['color']; $order_state->hidden = $v['hidden']; $order_state->delivery = $v['delivery']; $order_state->logable = $v['logable']; $order_state->invoice = $v['invoice']; $order_state->module_name = $this->name; if ($order_state->add()) { $source = dirname(__FILE__).'/icons/'.$v['icon'].'.gif'; $destination = dirname(__FILE__).'/../../img/os/'.(int)$order_state->id.'.gif'; copy($source, $destination); } Configuration::updateValue($k, (int)$order_state->id); } } At this point, no problem.The order states are being saved on config table. The problem is, i want set the mail template from installer instead of do manually from BO one by one for each language. See the attached, please. Its possible to do something like this? $order_state->mail_template[$language['id_lang']] = 'template_file_name';I checked the OrderState class but there's nothing about mail template settings.[/size] Thanks in advance Edited March 27, 2015 by omine (see edit history) Link to comment Share on other sites More sharing options...
omine Posted March 27, 2015 Author Share Posted March 27, 2015 Sorry for disturbing.. I'm reading again the file classes/order/OrderState.php I found the property "template" 'template' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isTplName', 'size' => 64),My code will be like this: $order_state->template[$language['id_lang']] = 'template_file_name'; 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