1

I am writing an extension for a new payment gateway. In payment controller for a validation purpose I am inspecting is there any products in cart, if not redirecting to cart. Code as below

<?php
     // other code goes here
     if(!$order->getId()){
         $this->_redirect('checkout/cart');
     }
     // other code goes here
?>

But it is not redirecting to cart. Can anyone suggest?

  • may be your issue in !$order->getId() ... You did not got the order object and – Amit Bera Aug 23 '15 at 13:37
  • @AmitBera I added a simple echo inside if, its printing. – Butterfly Aug 23 '15 at 13:43
  • 1
    missing return ; $this->_redirect('checkout/cart'); return; – Amit Bera Aug 23 '15 at 13:48
  • @AmitBera yes, its good catch.. Working now.. Post this as answer. – Butterfly Aug 23 '15 at 13:51
1

As per as commit missing is return. You need add return for execute redirection

 if(!$order->getId()){
         $this->_redirect('checkout/cart');
return;
     }

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.