Jump to content

How to display a button in Prestashop back office orders page?


Venky967

Recommended Posts

Thank you :)

 

I have extended my class .Now what must be included inside this in order to display a text or button.

 

class TuconfigureController extends AdminOrdersController

{

    public function __construct()

    {

        $this->bootstrap = true;

        $this->lang = (!isset($this->context->cookie) || !is_object($this->context->cookie)) ? intval(Configuration::get('PS_LANG_DEFAULT')) : intval($this->context->cookie->id_lang);

        parent::__construct();

    }

 

    public function initContent()

    {

        parent::initContent();

    }

 

 

}
Link to comment
Share on other sites

I am using prestashop 1.7.0.4

 

when we view  any one of the orders I want to add a button  in shipping address block.

 

I am specifying sample url where you can have an idea regarding page that i need to override 

controller=AdminOrders&id_order=5&vieworder&token=4e10ca68658d3e87902e5faaf8b4ef5c

post-1368481-0-19846200-1487407594_thumb.jpg

Edited by Venky967 (see edit history)
Link to comment
Share on other sites

At first, I thought you wanted to change the order list that's why I said you needed to change the orders controller.

 

The file you are searching to alter is the 

ADMIN_DIRECTORY/themes/default/template/controllers/orders/helpers/view/view.tpl

 There you can add your button and then if you want to bind it with an ajax call you should create in your override a function like the following

public function ajaxProcessMyFunction(){ ... }
Link to comment
Share on other sites

Thanks for your immediate replies.

 

Sorry that was not my question's intension.Let me clear it from beginning.

I have created a module named "Mymodule".Inside the module i have folders like

          Mymodule

                    controller(folder)

                              admin

                                   samplefile.php

                              front

                    override(folder)

                    views(folder)

                    mymodule.php file.

 

Above is my modules hierarchy 

 

My intension was to add a button below the shipping address through my own module without disturbing prestashop core files. Is it possible ?

If yes,please provide indetail regarding which files must be created inside the folders. :) 

 

 

 

Hope you understood.Thanks :)

Link to comment
Share on other sites

In your modules override folder add 

\controllers\admin\templates\orders\helpers\view\view.tpl

in that tpl copy the code from 

ADMIN_DIRECTORY/themes/default/template/controllers/orders/helpers/view/view.tpl

and make the changes you wish.

 

Re-install your module or just add manually the tpl file in the override folder of the PrestaShop installation and you are good to go!

Link to comment
Share on other sites

Thank you :)

 

Did the same thing you asked but didn't see any changes in the orders page. 

Things I have done:

            1. Copied the file from ADMIN_DIRECTORY/themes/default/template/controllers/orders/helpers/view/ and pasted in my module .../view/ (folder).

            2. Created anchor tag next to edit in shipping address block.

           3. Reinstalled my module and clicked on orders tab.

But found no change. 

 

Do we need to call this view.tpl from any function?

Link to comment
Share on other sites

well, that is the point of the override folder!Let me explain it to you.

Everything you have in the override folder of your modules on the installation should be copied inside the override folder of Prestashop. Prestashop does this automatically when you install the module but in this case, I don't know why it didn't. So feel free to add anything to the override folder! 

Link to comment
Share on other sites

Normally PrestaShop does this automatically when you install the module. There is a case though that it doesn't. This happens when another module has already created the same override so we have a conflict. 

 

My advice is to uninstall and delete the module from PrestaShop and then try reinstalling it if you have the correct file structure the override will be made!

Link to comment
Share on other sites

  • 2 years later...
  • 11 months later...
8 hours ago, Lucas said:

FYI: at least at PS 1.7 you have generic hooks for grid modifiers that allows you to do it. You can reuse existing actions or create your own:

https://devdocs.prestashop.com/1.7/development/components/grid/tutorials/work-with-row-actions/

in general you should avoid overrides when possible.

So that looks great but at this point the orders grid is not implemented using this methods yet.... :(

As an alternative, I'd suscribed a custom js using the actionAdminControllerSetMedia hook. That js add the button with a controller link that receive the order id from the row as a parameter.

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...