How to Add Coupon Code Column in Magento 2 Order Grid

How-to-Add-Coupon-Code-Column-in-Magento-2-Order-Grid

Order grid helps to add, track, and manage order details for quick and accurate order management. Fast, accurate, and flexible order processing is an inevitable part of any Magento 2 store.

The sales order grid in Magento 2 can be accessed in the admin panel under the “Sales” -> “Orders”. The default order grid offers order-related options like order ID, purchase date, grand total, order status, etc.

However, the default order grid is not enough when the admin wants to add a coupon code column! The requirement of columns in the order grid depends on the business.

The admin may want to monitor or get the details of the order placed using coupon code for marketing purposes. In that case, you may need to add coupon code column in Magento 2 order grid to provide a better workflow to store admins.

Use the below solution in order to do so.

Steps to Add Coupon Code Column in Magento 2 Order Grid

    1. Create registration.php file at app/code/Vendor/Module and use the below code.
    2. Create module.xml at app/code/Vendor/Module/etc and use the below code.
    3. Use the below code in the di.xml file at app/code/Vendor/Module/etc

    4. Create InstallSchema.php file at app/code/Vendor/Module/Setup

    5. Create sales_order_grid.xml at app/code/Vendor/Module/view/adminhtml/ui_component

    6. Execute the below commands.
    7. Execute the following SQL query

Add the column of coupon code and make better convenience in order grid in Magento 2.

The output of the above code displays like the below image:

how to add coupon code column in order grid in Magento 2

Do mention the doubts regarding this post in the Comments section below.

I would be happy to help.

Also, you can add any custom column in the order grid in Magento 2 based on your business requirements.

Feel free to share the solution with Magento Community via social media.

Thank You.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 12 Reviews)

Yash is a Magento Developer at Meetanshi. He loves playing computer games and watching action movies. For brain exercise, he likes to play Chess.

Leave a reply:

Your email address will not be published.