Search code examples
orocommerce

OroCommerce: Customize buttons on the Order view page?


I need to add my custom button to the order page, best if near edit/delete, it should just open link for some route with orderId parameter. Also it would be nice to remove unnecesary buttons like discount and coupon code.

How to do that? I tried to do smth with placeholders but didnt succeed.


Solution

  • Decided to use action as its very smart and powerful mechanism even for such simple thing as download button, dont need to override templates or work with templates at all. So here is all that need to display the button:

    #MyBundle/Resources/config/oro/actions.yml
    operations:
      download_action:
        label: Download
        button_options:
          icon: fa-download
        routes:
          - oro_order_view
        entities: ['Oro\Bundle\OrderBundle\Entity\Order']
        for_all_entities: false
        actions:
          - '@redirect':
              route: 'test_download'
              route_parameters: {id: $id}
              new_tab: true 
        preconditions:
          '@equal': [$internalStatus.id, 'open']
    

    The only confusing thing is that button appeared not only on oro_order_view page but on edit page too despite of specified route, anybody knows why?