Skip to content

Commit

Permalink
get itemIdentifier from item
Browse files Browse the repository at this point in the history
  • Loading branch information
cjonstrup committed Jul 31, 2023
1 parent 62ebe0f commit 7266fcd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Basket.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ public function setIdentifier(string $identifier): void
*/
protected function createItemIdentifier(ItemInterface $item): string
{
if(! empty($item->getItemIdentifier())) {
return $item->getItemIdentifier();
}

if (! array_key_exists('options', $item->toArray())) {
$item->options = [];
}
Expand Down
10 changes: 10 additions & 0 deletions src/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,14 @@ public function setQuantity(int $quantity): void
{
$this->data['quantity'] = $quantity;
}

/**
* Get itemIdentifier
*
* @return string
*/
public function getItemIdentifier(): string
{
return '';
}
}
7 changes: 7 additions & 0 deletions src/ItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ interface ItemInterface
*/
public function setIdentifier(string $identifier): void;

/**
* Return itemIdentifier.
*
* @return string
*/
public function getItemIdentifier(): string;

/**
* Return the total tax for this item.
*
Expand Down

0 comments on commit 7266fcd

Please sign in to comment.