How to create a plugin for after Place Order action checkout Magento 2?

You can create a plugin for after Place order action in Magento 2 using afterPlace() plugin method.

When you required to check or get data after place order in Magento 2 or save data to other tables after place order successfully You can use afterPlace plugin from OrderManagementInterface interface’s place() method.

place() method from the Magento\Sales\Api\OrderManagementInterface interface class used to Place order operation in Magento 2 from checkout page. Continue reading “How to create a plugin for after Place Order action checkout Magento 2?”

How to add timestamp column in sales_order_item table using db_schema.xml Magento 2?

You can add a new column, a field in sales_order_item table using db_schema.xml under your module, etc folder from Magento 2.3 and higher version.

We try to add a new column called item_expiry_date in sales_order_item table.

To add item_expiry_date field in table you need to only add one row inside the db_schema.xml file in your module.

Here, the Main table for Sales Item Operation is “sales_order_item” and you can add a new field in the table using below simple code snippet,

Here New Column type is a timestamp. You can add timestamp at item level using adding a new column in sales_order_item table.

Run command from Magento root instance,
php bin/magento setup:upgrade

Check the sales_order_item table in Database and one new column is added to the table and you can see new column.

Before place order checkout action plugin Magento 2.

You can create a plugin for Before Place order action In Magento 2 using beforePlace() method.

When you required to check or set data before place order in Magento 2, You can use a plugin for OrderManagementInterface interface place() method.

place() method from the Magento\Sales\Api\OrderManagementInterface interface class used to Place order operation in Magento 2 from checkout page.

Continue reading “Before place order checkout action plugin Magento 2.”