Jump to content

Creatin custom field in comment in order section

Recommended Posts

Hi! Im developing in Prestashop and I have a problem. In this part:"If you would like to add a comment about your order, please write it in the field below."  I want to put a custom checkbox field in order to appear like a message in  the backoffice if is submitted. I have already put the field and edit the php code in the orderopccontroller.php


                    switch (Tools::getValue('method'))
                        case 'update
                            if (Tools::isSubmit('message'))
                                $txtMessage = urldecode(Tools::getValue('message'));
                                if (count($this->errors))
                                    die('{"hasError" : true, "errors" : ["'.implode('\',\'', $this->errors).'"]}');
                            if (Tools::isSubmit('anonimo'))


I have also put in the parentordercontroller.php


            if (!Validate::isMessage($messageContent))
                $this->errors[] = Tools::displayError('Invalid message');
            else if ($oldMessage = Message::getMessageByCartId((int)($this->context->cart->id)))
                $message = new Message((int)($oldMessage['id_message']));
                $message->message = $messageContent;
                $message->anonimo = $_POST['anonimo'];
                $message = new Message();
                $message->message = $messageContent;
                $message->anonimo = $_POST['anonimo'];
                $message->id_cart = (int)($this->context->cart->id);
                $message->id_customer = (int)($this->context->cart->id_customer);

But is not working. Please somebody help me :( Please!

Edited by Juan Pablo Malkrovi (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...