1

is there a way to cancel the normal function in a Plugin and show some message?

Something like:

public function beforeSet(\Magento\Quote\Model\CouponManagement $subject, $cartId, $couponCode){

$variable = false;
if($variable){
  //do something and normal set triggers
}else{
  //stop set complete and show some text
}

}

Thank you in advance!

1 Answer 1

2

Use throw new exception exception method

 $message = __('Stop the function');
    throw new \Magento\Framework\Exception\LocalizedException($message);
    return;

NOTE: CODE TESTED

1
  • thank you it works for me
    – vDrews
    Jun 24, 2019 at 8:15

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.