Use instance in query if there are more than one instances and add tests

This commit is contained in:
Norris Oduro
2020-11-03 13:55:43 +00:00
parent 6d15ac8c43
commit 6ba97cafa8
2 changed files with 40 additions and 4 deletions

View File

@@ -98,7 +98,7 @@ class Cart
$instance = $instance->getInstanceIdentifier();
}
$this->instance = 'cart.'.$instance;
$this->instance = 'cart.' . $instance;
return $this;
}
@@ -831,7 +831,11 @@ class Cart
*/
private function storedCartWithIdentifierExists($identifier)
{
return $this->getConnection()->table($this->getTableName())->where('identifier', $identifier)->where('instance', $this->currentInstance())->exists();
$data = ['identifier' => $identifier];
if ($this->countInstances() > 1) {
$data['instance'] = $this->currentInstance();
}
return $this->getConnection()->table($this->getTableName())->where($data)->exists();
}
/**