@@ -382,15 +382,38 @@ public function removeItemCondition($itemId, $conditionName)
382382
383383 $ tempConditionsHolder = $ item ['conditions ' ];
384384
385- foreach ($ tempConditionsHolder as $ k => $ condition )
385+ // if the item's conditions is in array format
386+ // we will iterate through all of it and check if the name matches
387+ // to the given name the user wants to remove, if so, remove it
388+ if ( is_array ($ tempConditionsHolder ) )
386389 {
387- if ( $ condition -> getName () == $ conditionName )
390+ foreach ( $ tempConditionsHolder as $ k => $ condition )
388391 {
389- unset($ tempConditionsHolder [$ k ]);
392+ if ( $ condition ->getName () == $ conditionName )
393+ {
394+ unset($ tempConditionsHolder [$ k ]);
395+ }
390396 }
397+
398+ $ item ['conditions ' ] = $ tempConditionsHolder ;
391399 }
392400
393- $ item ['conditions ' ] = $ tempConditionsHolder ;
401+ // if the item condition is not an array, we will check if it is
402+ // an instance of a Condition, if so, we will check if the name matches
403+ // on the given condition name the user wants to remove, if so,
404+ // lets just make $item['conditions'] an empty array as there's just 1 condition on it anyway
405+ else
406+ {
407+ $ conditionInstance = "Darryldecode \\Cart \\CartCondition " ;
408+
409+ if ($ item ['conditions ' ] instanceof $ conditionInstance )
410+ {
411+ if ($ tempConditionsHolder ->getName () == $ conditionName )
412+ {
413+ $ item ['conditions ' ] = array ();
414+ }
415+ }
416+ }
394417 }
395418
396419 $ this ->update ($ itemId , array (
@@ -591,6 +614,17 @@ protected function saveConditions($conditions)
591614 */
592615 protected function itemHasConditions ($ item )
593616 {
594- return count ($ item ['conditions ' ]) > 0 ;
617+ if ( ! isset ($ item ['conditions ' ]) ) return false ;
618+
619+ if ( is_array ($ item ['conditions ' ]) )
620+ {
621+ return count ($ item ['conditions ' ]) > 0 ;
622+ }
623+
624+ $ conditionInstance = "Darryldecode \\Cart \\CartCondition " ;
625+
626+ if ( $ item ['conditions ' ] instanceof $ conditionInstance ) return true ;
627+
628+ return false ;
595629 }
596630}
0 commit comments