putocito Posted April 21, 2016 Share Posted April 21, 2016 Hi everyone. I look everywhere but couldnt find a solution yet. How can we add new variables to the backoffice_order email template? When creating backoffice order, I want to add the "Order Message" we enter to be visible in the email too. Plus I want to add customer email and password too. Link to comment Share on other sites More sharing options...
putocito Posted April 22, 2016 Author Share Posted April 22, 2016 (edited) Now I can add customer email in the email by editing /controllers/admin/AdminOrdersController.php #1871 I added '{email}' => $customer->email. But I am having problem with "Order message" part to show in the email template; I tried; '{message}' => Tools::nl2br($order_message), or '{message}' => Tools::nl2br($message), didnt print the messages in the email. How can we add the content of "order message" field when creating order from "backoffice order"? email template is backoffice_order Edited April 22, 2016 by putocito (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted April 22, 2016 Share Posted April 22, 2016 I don't think it's going to be easy.First, get the order id with Order::getOrderByCartId($cart->id)Then, you can try with $order->getFirstMessage() if that's the first and only one (as it should) Link to comment Share on other sites More sharing options...
putocito Posted April 23, 2016 Author Share Posted April 23, 2016 (edited) Thank you Nemo for the information. But in backoffice order creation, message should be send to email before creating the order. So id_order is 0, Incase anyone needed, Solution I hack is I added another function to Cart.php public function getBackofficeOrderMessage() { return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT `message` FROM `'._DB_PREFIX_.'message` WHERE `id_cart` = '.(int)$this->id.' ORDER BY `id_message` '); } and then call that from AdminOrdersController.php and assign to mailvars. '{order_message}' => $cart->getBackofficeOrderMessage() Edited April 23, 2016 by putocito (see edit history) 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