1

I try to take the final product list after the checkout, so I create an observer for that. I found a list of all dispatched events in Magento 2.1 which looks like this:

dispatched-events

I tried a lot of events, which is work properly, but nothing seems to work for the final checkout button.

I also tried checkout_cart_save_after but this event is before the final checkout button, and checkout_type_onepage_save_order_afterbut this event is not working.

Does anyone know how to solve this problem? Or which event is responsible for this?

0

I think you have to use the event sales_order_place_after. This event will work on final checkout (Place Order) button.

Get order data :

$order = $observer->getEvent()->getOrder();
$order_id = $order->getIncrementId();
foreach($order->getAllItems() as $item){
      $ProdustIds[]= $item->getProductId();
      $proName[] = $item->getName(); // product name
 }
$shippingAddress = $order->getShippingAddress(); // shipping address
$customer = $order->getCustomerId(); // using this id you can get customer name
10
  • so with this event i can obtain the final prodcut list? – Alin Lupoiu Nov 22 '16 at 8:06
  • @AlinLupoiu, Yes, This event will give you final order and its item list at the time of order placement. – Ashish Jagnani Nov 22 '16 at 8:08
  • and do you have any idea how to take the item list in my observer? – Alin Lupoiu Nov 22 '16 at 8:11
  • @AlinLupoiu, Check my updated answer – Ashish Jagnani Nov 22 '16 at 8:15
  • @AlinLupoiu, If this answer resolved the issue then mark as accepted so that other user will get help from this if they have similar issue. – Ashish Jagnani Nov 22 '16 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.