File tree Expand file tree Collapse file tree 2 files changed +27
-13
lines changed
app/code/Magento/Checkout/Controller Expand file tree Collapse file tree 2 files changed +27
-13
lines changed Original file line number Diff line number Diff line change @@ -118,12 +118,7 @@ protected function getBackUrl($defaultUrl = null)
118
118
return $ returnUrl ;
119
119
}
120
120
121
- $ shouldRedirectToCart = $ this ->_scopeConfig ->getValue (
122
- 'checkout/cart/redirect_to_cart ' ,
123
- \Magento \Store \Model \ScopeInterface::SCOPE_STORE
124
- );
125
-
126
- if ($ shouldRedirectToCart || $ this ->getRequest ()->getParam ('in_cart ' )) {
121
+ if ($ this ->shouldRedirectToCart () || $ this ->getRequest ()->getParam ('in_cart ' )) {
127
122
if ($ this ->getRequest ()->getActionName () == 'add ' && !$ this ->getRequest ()->getParam ('in_cart ' )) {
128
123
$ this ->_checkoutSession ->setContinueShoppingUrl ($ this ->_redirect ->getRefererUrl ());
129
124
}
@@ -132,4 +127,15 @@ protected function getBackUrl($defaultUrl = null)
132
127
133
128
return $ defaultUrl ;
134
129
}
130
+
131
+ /**
132
+ * @return bool
133
+ */
134
+ protected function shouldRedirectToCart ()
135
+ {
136
+ return $ this ->_scopeConfig ->isSetFlag (
137
+ 'checkout/cart/redirect_to_cart ' ,
138
+ \Magento \Store \Model \ScopeInterface::SCOPE_STORE
139
+ );
140
+ }
135
141
}
Original file line number Diff line number Diff line change @@ -122,13 +122,21 @@ public function execute()
122
122
123
123
if (!$ this ->_checkoutSession ->getNoCartRedirect (true )) {
124
124
if (!$ this ->cart ->getQuote ()->getHasError ()) {
125
- $ this ->messageManager ->addComplexSuccessMessage (
126
- 'addCartSuccessMessage ' ,
127
- [
128
- 'product_name ' => $ product ->getName (),
129
- 'cart_url ' => $ this ->getCartUrl (),
130
- ]
131
- );
125
+ if ($ this ->shouldRedirectToCart ()) {
126
+ $ message = __ (
127
+ 'You added %1 to your shopping cart. ' ,
128
+ $ product ->getName ()
129
+ );
130
+ $ this ->messageManager ->addSuccessMessage ($ message );
131
+ } else {
132
+ $ this ->messageManager ->addComplexSuccessMessage (
133
+ 'addCartSuccessMessage ' ,
134
+ [
135
+ 'product_name ' => $ product ->getName (),
136
+ 'cart_url ' => $ this ->getCartUrl (),
137
+ ]
138
+ );
139
+ }
132
140
}
133
141
return $ this ->goBack (null , $ product );
134
142
}
You can’t perform that action at this time.
0 commit comments