Skip to content

Commit 7eab840

Browse files
authored
Update Cart.php
1 parent 3161067 commit 7eab840

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/Cart.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,32 @@ public function getItem($row_id)
419419
? false
420420
: $this->cartContents[ $row_id ];
421421
}
422+
423+
// ------------------------------------------------------------------------
422424

425+
/**
426+
* Find cart item
427+
*
428+
* Returns the details of a specific item in the cart
429+
*
430+
* @param $key
431+
* @param $value
432+
* @return bool|mixed
433+
*/
434+
public function find($key, $value)
435+
{
436+
if($this->totalItems() == 0){
437+
return false;
438+
}else{
439+
foreach($this->cartContents as $row){
440+
if(isset($row[$key]) && $row[$key] == $value){
441+
return $row;
442+
}
443+
}
444+
return false;
445+
}
446+
}
447+
423448
// ------------------------------------------------------------------------
424449

425450
/**

0 commit comments

Comments
 (0)