I want to run an observer function depend on payment method, how can I do this?
public function CompleteOrder($observer)
{
......
}
Now I want to run this function only when payment method is cashondelivery
....!
when I use code below, in the frontend, when customer click on final button for checkout, if payment method be not cashondelivery
then order can not be completed!
public function CompleteOrder($observer)
{
$method = $observer->getEvent()->getMethodInstance();
if ($method->getCode() == 'cashondelivery')
{
...
} else {
return false;
}