File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -304,6 +304,30 @@ public function getCondition($conditionName)
304304 {
305305 return $ this ->getConditions ()->get ($ conditionName );
306306 }
307+
308+ /**
309+ * Get all the condition filtered by Type
310+ * @param $type
311+ * @return CartConditionCollection
312+ */
313+ public function getConditionsByType ($ type ){
314+ return $ this ->getConditions ()->filter (function (CartCondition $ condition ) use ($ type ){
315+ return $ condition ->getType () == $ type ;
316+ });
317+ }
318+
319+
320+ /**
321+ * Remove all the condition with the $type specified
322+ * @param $type
323+ * @return $this
324+ */
325+ public function removeConditionsByType ($ type ){
326+ return $ this ->getConditionsByType ($ type )->each (function ($ condition ){
327+ $ this ->removeCartCondition ($ condition ->getName ());
328+ });
329+ }
330+
307331
308332 /**
309333 * removes a condition on a cart by condition name,
@@ -559,4 +583,4 @@ protected function itemHasConditions($item)
559583 {
560584 return count ($ item ['conditions ' ]) > 0 ;
561585 }
562- }
586+ }
You can’t perform that action at this time.
0 commit comments