File tree Expand file tree Collapse file tree 3 files changed +7
-27
lines changed
Sales/Controller/Adminhtml/Order/Create Expand file tree Collapse file tree 3 files changed +7
-27
lines changed Original file line number Diff line number Diff line change @@ -168,11 +168,17 @@ private function addItemToCart(
168168 $ stockItemQuantity
169169 );
170170 }
171-
171+ //here $result has errors
172172 if (is_string ($ result )) {
173173 foreach (array_unique (explode ("\n" , $ result )) as $ error ) {
174174 $ errors [] = $ this ->error ->create (__ ($ error )->render (), $ cartItemPosition , $ stockItemQuantity );
175175 }
176+ } elseif ($ result ->getHasError () && $ result ->getStockStateResult ()->getHasError ()) {
177+ $ errors [] = $ this ->error ->create (
178+ __ ($ result ->getStockStateResult ()->getMessage ())->render (),
179+ $ cartItemPosition ,
180+ $ stockItemQuantity
181+ );
176182 }
177183
178184 return $ errors ;
Original file line number Diff line number Diff line change @@ -1668,8 +1668,6 @@ public function addProduct(
16681668 }
16691669
16701670 $ parentItem = null ;
1671- $ errors = [];
1672- $ item = null ;
16731671 $ items = [];
16741672 foreach ($ cartCandidates as $ candidate ) {
16751673 // Child items can be sticked together only within their parent
Original file line number Diff line number Diff line change @@ -130,28 +130,4 @@ public function execute()
130130
131131 return $ resultRedirect ;
132132 }
133-
134- /**
135- * Collect all item errors
136- *
137- * @param $order
138- * @return array
139- */
140- private function getItemErrors ($ order ): array
141- {
142- $ errors = [];
143- $ items = $ order ->getAllItems ();
144- foreach ($ items as $ item ) {
145- if (!$ item ->getMessage (false )) {
146- continue ;
147- }
148- foreach ($ item ->getMessage (false ) as $ message ) {
149- if (!in_array ($ message , $ errors )) {
150- $ errors [] = $ message ;
151- }
152- }
153- }
154-
155- return $ errors ;
156- }
157133}
You can’t perform that action at this time.
0 commit comments