Skip to content

Commit

Permalink
Access basket item by _id (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcosca committed Sep 22, 2018
1 parent b06d641 commit 45b0c4e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion basket.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ function find($key=NULL,$val=NULL) {
if (isset($_SESSION[$this->key])) {
foreach ($_SESSION[$this->key] as $id=>$item)
if (!isset($key) ||
array_key_exists($key,$item) && $item[$key]==$val) {
array_key_exists($key,$item) && $item[$key]==$val ||
$key=='_id' && $id==$val) {
$obj=clone($this);
$obj->id=$id;
$obj->item=$item;
Expand Down

0 comments on commit 45b0c4e

Please sign in to comment.