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?

1 Answer 1

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? Nov 22, 2016 at 8:06
  • @AlinLupoiu, Yes, This event will give you final order and its item list at the time of order placement. Nov 22, 2016 at 8:08
  • and do you have any idea how to take the item list in my observer? Nov 22, 2016 at 8:11
  • @AlinLupoiu, Check my updated answer Nov 22, 2016 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. Nov 22, 2016 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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