Hi i have use a plugin feature in my module to check the zipcode is available in the module or not .Which works fine but on validating i have set the error message like
$result = $connection->fetchAll("SELECT shipregioncodes FROM shipregioncodes_shipregioncodes WHERE shipregioncodes=$postcode");
$count = count($result);
if($count==0){
        $this->_messageManager->addError("hiiiiiiii");
        throw new NoSuchEntityException(
            __('Shipping is not available on provided zipcode %1', $postcode)
        );
}
it only shows the message in the console not on the site.Please suggest me how can i fix this. thanks
Hi i got this done by using the below code using StateException
 if($count==0){
        throw new StateException(__('Shipping is not available on the provided zipcode.'));
 }
don't forget to include
use Magento\Framework\Exception\StateException;
:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With