Magento 2: How to redirect to checkout page after product added to cart via Observer/Plugin from category page?Magento2 redirecting to Shopping cartMagento 2: Skipping Shopping Cart Page after Add to CartMagento 2 : Add to Cart Button redirect to contact pageMagento 2: Redirect from Observer Not Working on Category PageRedirect to Category Page after “Add to Cart”Redirect to another category from observerCheckout: How to redirect back to cart after customer logged in within the onepage checkout process?Magento 2: Skipping Shopping Cart Page after Add to CartRedirect Page From ObserverGetting cart empty after redirect issueMagento 2: Redirect from Observer Not Working on Category PageMagento 2 - How to show not visible individually products in mini cart?Redirect from plugin Magento 2Magento 2 plugin change price of products that have a custom attribute with
What is the most common color to indicate the input-field is disabled?
How do I deal with an unproductive colleague in a small company?
Why no variance term in Bayesian logistic regression?
Is it inappropriate for a student to attend their mentor's dissertation defense?
How dangerous is XSS?
If human space travel is limited by the G force vulnerability, is there a way to counter G forces?
Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?
I would say: "You are another teacher", but she is a woman and I am a man
How to show a landlord what we have in savings?
Could the museum Saturn V's be refitted for one more flight?
Should I cover my bicycle overnight while bikepacking?
How would I stat a creature to be immune to everything but the Magic Missile spell? (just for fun)
Would Slavery Reparations be considered Bills of Attainder and hence Illegal?
How do I gain back my faith in my PhD degree?
Is "remove commented out code" correct English?
How to tell a function to use the default argument values?
Unable to supress ligatures in headings which are set in Caps
What are some good books on Machine Learning and AI like Krugman, Wells and Graddy's "Essentials of Economics"
Short story with a alien planet, government officials must wear exploding medallions
Why didn't Boeing produce its own regional jet?
Is it acceptable for a professor to tell male students to not think that they are smarter than female students?
Bullying boss launched a smear campaign and made me unemployable
Which is the best way to check return result?
Apex Framework / library for consuming REST services
Magento 2: How to redirect to checkout page after product added to cart via Observer/Plugin from category page?
Magento2 redirecting to Shopping cartMagento 2: Skipping Shopping Cart Page after Add to CartMagento 2 : Add to Cart Button redirect to contact pageMagento 2: Redirect from Observer Not Working on Category PageRedirect to Category Page after “Add to Cart”Redirect to another category from observerCheckout: How to redirect back to cart after customer logged in within the onepage checkout process?Magento 2: Skipping Shopping Cart Page after Add to CartRedirect Page From ObserverGetting cart empty after redirect issueMagento 2: Redirect from Observer Not Working on Category PageMagento 2 - How to show not visible individually products in mini cart?Redirect from plugin Magento 2Magento 2 plugin change price of products that have a custom attribute with
I have followed below & it works fine
Magento 2 : Add to Cart Button redirect to contact page
Only issue it should be redirected after product is added to cart.
I have tried different methods but seems not working http://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html
I tried using Observer but unable to redirect from Observer because of AJAX. It it's not AJAX then it works fine.
If somebody can guide how to redirect from Checkout page after product is added to cart. It would be better.
I'm using Porto Theme. So don't want to remove AJAX feature while Add to Cart
[UPDATE]
Through plugin I have achieved. Need to achieve something using Observer
public function afterExecute(MagentoCheckoutControllerCartAdd $subject, $result)
$result = [];
$result['backUrl'] = $this->url->getUrl('checkout');
$subject->getResponse()->representJson($this->objectManager->get('MagentoFrameworkJsonHelperData')->jsonEncode($result));
return;
magento2 event-observer custom redirect plugin
bumped to the homepage by Community♦ 8 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have followed below & it works fine
Magento 2 : Add to Cart Button redirect to contact page
Only issue it should be redirected after product is added to cart.
I have tried different methods but seems not working http://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html
I tried using Observer but unable to redirect from Observer because of AJAX. It it's not AJAX then it works fine.
If somebody can guide how to redirect from Checkout page after product is added to cart. It would be better.
I'm using Porto Theme. So don't want to remove AJAX feature while Add to Cart
[UPDATE]
Through plugin I have achieved. Need to achieve something using Observer
public function afterExecute(MagentoCheckoutControllerCartAdd $subject, $result)
$result = [];
$result['backUrl'] = $this->url->getUrl('checkout');
$subject->getResponse()->representJson($this->objectManager->get('MagentoFrameworkJsonHelperData')->jsonEncode($result));
return;
magento2 event-observer custom redirect plugin
bumped to the homepage by Community♦ 8 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
magento.stackexchange.com/a/100417/42720 this?
– Volvox
Jun 9 '17 at 7:24
Below is an answer to redirect to checkout by overriding template file, you can check here magento.stackexchange.com/a/240628/44358
– Nitesh
Sep 3 '18 at 12:53
add a comment |
I have followed below & it works fine
Magento 2 : Add to Cart Button redirect to contact page
Only issue it should be redirected after product is added to cart.
I have tried different methods but seems not working http://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html
I tried using Observer but unable to redirect from Observer because of AJAX. It it's not AJAX then it works fine.
If somebody can guide how to redirect from Checkout page after product is added to cart. It would be better.
I'm using Porto Theme. So don't want to remove AJAX feature while Add to Cart
[UPDATE]
Through plugin I have achieved. Need to achieve something using Observer
public function afterExecute(MagentoCheckoutControllerCartAdd $subject, $result)
$result = [];
$result['backUrl'] = $this->url->getUrl('checkout');
$subject->getResponse()->representJson($this->objectManager->get('MagentoFrameworkJsonHelperData')->jsonEncode($result));
return;
magento2 event-observer custom redirect plugin
I have followed below & it works fine
Magento 2 : Add to Cart Button redirect to contact page
Only issue it should be redirected after product is added to cart.
I have tried different methods but seems not working http://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html
I tried using Observer but unable to redirect from Observer because of AJAX. It it's not AJAX then it works fine.
If somebody can guide how to redirect from Checkout page after product is added to cart. It would be better.
I'm using Porto Theme. So don't want to remove AJAX feature while Add to Cart
[UPDATE]
Through plugin I have achieved. Need to achieve something using Observer
public function afterExecute(MagentoCheckoutControllerCartAdd $subject, $result)
$result = [];
$result['backUrl'] = $this->url->getUrl('checkout');
$subject->getResponse()->representJson($this->objectManager->get('MagentoFrameworkJsonHelperData')->jsonEncode($result));
return;
magento2 event-observer custom redirect plugin
magento2 event-observer custom redirect plugin
edited Apr 13 '17 at 12:55
Community♦
1
1
asked Mar 8 '17 at 3:19
Ankit ShahAnkit Shah
4,951967144
4,951967144
bumped to the homepage by Community♦ 8 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 8 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
magento.stackexchange.com/a/100417/42720 this?
– Volvox
Jun 9 '17 at 7:24
Below is an answer to redirect to checkout by overriding template file, you can check here magento.stackexchange.com/a/240628/44358
– Nitesh
Sep 3 '18 at 12:53
add a comment |
magento.stackexchange.com/a/100417/42720 this?
– Volvox
Jun 9 '17 at 7:24
Below is an answer to redirect to checkout by overriding template file, you can check here magento.stackexchange.com/a/240628/44358
– Nitesh
Sep 3 '18 at 12:53
magento.stackexchange.com/a/100417/42720 this?
– Volvox
Jun 9 '17 at 7:24
magento.stackexchange.com/a/100417/42720 this?
– Volvox
Jun 9 '17 at 7:24
Below is an answer to redirect to checkout by overriding template file, you can check here magento.stackexchange.com/a/240628/44358
– Nitesh
Sep 3 '18 at 12:53
Below is an answer to redirect to checkout by overriding template file, you can check here magento.stackexchange.com/a/240628/44358
– Nitesh
Sep 3 '18 at 12:53
add a comment |
1 Answer
1
active
oldest
votes
try this code.
use MagentoFrameworkEventObserverInterface;
class TestObserver implements ObserverInterface
protected $_responseFactory;
protected $_url;
public function __construct(MagentoFrameworkAppResponseFactory $responseFactory,
MagentoFrameworkUrlInterface $url)
$this->_responseFactory = $responseFactory;
$this->_url = $url;
public function execute(MagentoFrameworkEventObserver $observer)
$cartUrl = $this->_url->getUrl('checkout/cart/index');
$this->_responseFactory->create()->setRedirect($cartUrl)->sendResponse();
exit;
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f163322%2fmagento-2-how-to-redirect-to-checkout-page-after-product-added-to-cart-via-obse%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
try this code.
use MagentoFrameworkEventObserverInterface;
class TestObserver implements ObserverInterface
protected $_responseFactory;
protected $_url;
public function __construct(MagentoFrameworkAppResponseFactory $responseFactory,
MagentoFrameworkUrlInterface $url)
$this->_responseFactory = $responseFactory;
$this->_url = $url;
public function execute(MagentoFrameworkEventObserver $observer)
$cartUrl = $this->_url->getUrl('checkout/cart/index');
$this->_responseFactory->create()->setRedirect($cartUrl)->sendResponse();
exit;
add a comment |
try this code.
use MagentoFrameworkEventObserverInterface;
class TestObserver implements ObserverInterface
protected $_responseFactory;
protected $_url;
public function __construct(MagentoFrameworkAppResponseFactory $responseFactory,
MagentoFrameworkUrlInterface $url)
$this->_responseFactory = $responseFactory;
$this->_url = $url;
public function execute(MagentoFrameworkEventObserver $observer)
$cartUrl = $this->_url->getUrl('checkout/cart/index');
$this->_responseFactory->create()->setRedirect($cartUrl)->sendResponse();
exit;
add a comment |
try this code.
use MagentoFrameworkEventObserverInterface;
class TestObserver implements ObserverInterface
protected $_responseFactory;
protected $_url;
public function __construct(MagentoFrameworkAppResponseFactory $responseFactory,
MagentoFrameworkUrlInterface $url)
$this->_responseFactory = $responseFactory;
$this->_url = $url;
public function execute(MagentoFrameworkEventObserver $observer)
$cartUrl = $this->_url->getUrl('checkout/cart/index');
$this->_responseFactory->create()->setRedirect($cartUrl)->sendResponse();
exit;
try this code.
use MagentoFrameworkEventObserverInterface;
class TestObserver implements ObserverInterface
protected $_responseFactory;
protected $_url;
public function __construct(MagentoFrameworkAppResponseFactory $responseFactory,
MagentoFrameworkUrlInterface $url)
$this->_responseFactory = $responseFactory;
$this->_url = $url;
public function execute(MagentoFrameworkEventObserver $observer)
$cartUrl = $this->_url->getUrl('checkout/cart/index');
$this->_responseFactory->create()->setRedirect($cartUrl)->sendResponse();
exit;
answered Mar 8 '17 at 3:29
Dhiren VasoyaDhiren Vasoya
4,38151844
4,38151844
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f163322%2fmagento-2-how-to-redirect-to-checkout-page-after-product-added-to-cart-via-obse%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
magento.stackexchange.com/a/100417/42720 this?
– Volvox
Jun 9 '17 at 7:24
Below is an answer to redirect to checkout by overriding template file, you can check here magento.stackexchange.com/a/240628/44358
– Nitesh
Sep 3 '18 at 12:53