Error Use of exit language construct is discouraged

Viewed 19

Use of exit language construct is discouraged.

if ($attribute_name == $customerGroup) { if ($dropdown_field > $Quantity) {

                    $this->messageManager->addError($this->helper->getGeneralConfig('minimum_alertmsg') . $dropdown_field);
                    $cartUrl = $this->_url->getUrl('checkout/cart');
                 $this->_responseFactory->create()->setRedirect($cartUrl)->sendResponse();
                 
                   Exit();
                }
            }

need to redirect in check out page without using exit(); and die();

1 Answers

i Got The Solution

Using Javascript We Can Remove Error "Use of exit language construct is discouraged"

if ($attribute_name == $customerGroup) { if ($dropdown_field > $Quantity) {

                    $this->messageManager->addError($this->helper->getGeneralConfig('minimum_alertmsg') . $dropdown_field);
                    $cartUrl = $this->_url->getUrl('checkout/cart');       
                   
                    ?>
                        <script type="text/javascript">
                            window.location.href = "<?=  $cartUrl; ?> ";
                        </script>

                    <?php
                }
            }
Related