pojezdy.eu Posted December 23, 2024 Share Posted December 23, 2024 Hello all, would someone recommend me how to update PaymentModule.php (I guess that should be the one, as far as I search over forums) to copy the message content into the note stored in the note cell of ps_order table? I guess it should be somewhere here ... if (!empty($message)) { $msg = new Message(); $message = strip_tags($message, '<br>'); if (Validate::isCleanHtml($message)) { if (self::DEBUG_MODE) { PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true); } $msg->message = $message; $msg->id_cart = (int) $id_cart; $msg->id_customer = (int) ($order->id_customer); $msg->id_order = (int) $order->id; $msg->private = 1; $msg->add(); } } Link to comment Share on other sites More sharing options...
pojezdy.eu Posted December 23, 2024 Author Share Posted December 23, 2024 PrestaShop version is 1.7. Link to comment Share on other sites More sharing options...
webprog Posted December 24, 2024 Share Posted December 24, 2024 (edited) Hello, there is no field NOTE in table ORDERS in early prestashop 1.7 versions. The NOTE field have appeared in later prestashop 1.7 versions. Then, you can try this code: if (!empty($message) && Validate::isCleanHtml($message)) { // Retrieve the last created order for the current cart $order = Order::getByCartId((int)$id_cart); if ($order) { // Sanitize the message $cleanMessage = strip_tags($message, '<br>'); // Update the note field in the orders table Db::getInstance()->update( 'orders', ['note' => pSQL($cleanMessage)], 'id_order = ' . (int)$order->id ); } } Edited December 24, 2024 by webprog (see edit history) 1 Link to comment Share on other sites More sharing options...
pojezdy.eu Posted December 25, 2024 Author Share Posted December 25, 2024 Thanks a lot. It was helpful hint I use PS1.7.8. where Note is already implemented. I have a module which shows Note field in the order list, while Message is hidden and it cause me troubles during preparation of the orders. I may miss some instructions. With this update, I can get what I need and see there is something to take care from the order list and order preview. Finally, I was looking on wrong part of the code. This command is the final one. // Updateing note in the order according to customer message - if ansy. Db::getInstance()->Execute("UPDATE `ps_orders` SET `note`='" . $note . "' WHERE `id_order` = " . (int)$order->id . ";"); I had to create a $note variable and assign value in this part, to keep it once order is created, executing than SQL command above. if ($old_message && !$old_message['private']) { $update_message = new Message((int) $old_message['id_message']); $update_message->id_order = (int) $order->id; $update_message->update(); // Add this message in the customer thread $customer_thread = new CustomerThread(); $customer_thread->id_contact = 0; $customer_thread->id_customer = (int) $order->id_customer; $customer_thread->id_shop = (int) $this->context->shop->id; $customer_thread->id_order = (int) $order->id; $customer_thread->id_lang = (int) $this->context->language->id; $customer_thread->email = $this->context->customer->email; $customer_thread->status = 'open'; $customer_thread->token = Tools::passwdGen(12); $customer_thread->add(); $customer_message = new CustomerMessage(); $customer_message->id_customer_thread = $customer_thread->id; $customer_message->id_employee = 0; $customer_message->message = $update_message->message; $customer_message->private = 0; // Prepare data for the note field in the orders table if (!empty($update_message->message) && Validate::isCleanHtml($update_message->message)) { $note = strip_tags($update_message->message, '<br>'); } if (!$customer_message->add()) { $this->errors[] = $this->trans('An error occurred while saving message', [], 'Admin.Payment.Notification'); } Link to comment Share on other sites More sharing options...
lonzobrown Posted February 19 Share Posted February 19 HI there I we are working on services based website that is related to health care services like Mental health, sexologist in Islamabad, child psychologist in Islamabad and more we see that people a Book fake APPOINTMENT how to go thro it and can any one the solution for that. 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