1

I want to redirect set Cash On Delivery Payment method so how can it be done?

Means After cash on delivery redirect a page in Magento 2

  • it when a customer select on cash on delivery method and after that when click place order button it will redirect to your custom page? – Amit Bera Nov 27 '19 at 7:32
0

in your events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_order_place_after">
        <observer name="neo_ordercomment_observer_orderneo" instance="Neo\OrderComment\Observer\Orderneo" />
    </event>
</config>

Here is my events.xml

And my observer file is Orderneo file,

namespace Neo\OrderComment\Observer;

class Orderneo implements \Magento\Framework\Event\ObserverInterface
{
    public function execute(
            \Magento\Framework\Event\Observer $observer,
            \Magento\Framework\App\Action\Context $context 
     ){
     $order = $observer->getEvent()->getOrder();
     if($order->getPaymentType()=='cashPayment')
     {
           $resultRedirect->setUrl('frontname/controller');
           return $resultRedirect;
     }
    }
}

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.