Reading list Switch to dark mode

    How to add additional action buttons in the Admin Orders main buttons bar

    Updated 14 November 2023

    In this blog, we are about to learn, how to add additional action buttons in the admin orders main buttons bar for extra actions.

    You can create a module as per your requirements and use this feature to extend the functionality of your module. To extend this feature, we need to follow the steps as follows.

    First of all, we need to register a new hook named ‘actionGetAdminOrderButtons’

    We use this hook to display additional action buttons in the admin orders main buttons bar.

    Now we use the statement followed by the imported class namespace above the class declaration:

    Searching for an experienced
    Prestashop Company ?
    Find out More
    use PrestaShopBundle\Controller\Admin\Sell\Order\ActionsBarButton;


    Now we define the definition of hook functionality as Follows:

        /**
         * Add buttons to main buttons bar
         */
        public function hookActionGetAdminOrderButtons(array $params)
        {
            $order = new Order($params['id_order']);
    
            /** @var \Symfony\Bundle\FrameworkBundle\Routing\Router $router */
            $router = $this->get('router');
    
            /** @var ActionsBarButtonsCollection $bar */
            $bar = $params['actions_bar_buttons_collection'];
    
            $createAnOrderUrl = $router->generate('admin_orders_create');
            $bar->add(
                new ActionsBarButton(
                    'btn-info', ['href' => $createAnOrderUrl], 'Create an order'
                )
            );
    
            $viewCustomerUrl = $router->generate('admin_customers_view', ['customerId'=> (int)$order->id_customer]);
            $bar->add(
                new ActionsBarButton(
                    'btn-secondary', ['href' => $viewCustomerUrl], 'View customer'
                )
            );
    
            $shopLink =  Context::getContext()->shop->getBaseURL(true);
            $bar->add(
                new ActionsBarButton(
                    'btn-link', ['href' => $shopLink], 'Go to Shop'
                )
            );
    
            $productLink =  Context::getContext()->link->getAdminLink('AdminProducts');
            $bar->add(
                new ActionsBarButton(
                    'btn-dark', ['href' => $productLink], 'Go to Catalog'
                )
            );        
        }

    You will get the results as follows:

    Additional action buttons
    Additional action buttons

    With $router = $this->get('router'); we inject the router capable to generate URL links to controller actions from routes and their parameters. For example:

    <?php
    $viewCustomerUrl = $router->generate('admin_customers_view', ['customerId'=> (int)$order->id_customer]);

    And also we use ActionsBarButtonsCollection to add our new ActionsBarButton buttons. And just with this small function, we get a nice result (View customer and More actions buttons added).


    There are two types of display buttons:
    1. Display the individual action button like View customer
    2. Display one action button and other all buttons will be displayed as a dropdown “… More actions”

    Note: The second type of display will be automatically set when there are more than two action buttons otherwise it will be shown as individual action buttons

    That’s all about this blog.

    If any issues or doubts with the above step, please feel free to let us know in the comment section.

    We would be happy to help.

    You can also explore our PrestaShop Development Services and a large range of quality PrestaShop Modules.

    For any doubt contact us at [email protected].


    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home