<?php


namespace Magetop\Advancepreview\Observer\Frontend;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
class AfterPlaceOrderDesign implements ObserverInterface
{
    protected $messageManager;
    protected $customerSession;
    public function __construct(
        \Magento\Framework\Message\ManagerInterface $messageManager,
        \Magento\Customer\Model\Session $customerSession
    )
    {
        $this->messageManager = $messageManager;
        $this->customerSession = $customerSession;
    }

    public function execute(Observer $observer)
    {
        $isPlaceOrderDesign = $this->customerSession->getPlacePreviewOrderSuccess();
        if($isPlaceOrderDesign == 1) {
            $this->messageManager->addSuccessMessage(__('Order placed successfully'));
            $this->customerSession->setPlacePreviewOrderSuccess(0);
        }
    }
}
