Skip to content

Commit

Permalink
Pass meta data to basketable get price allowing for variations to hav…
Browse files Browse the repository at this point in the history
…e different prices
  • Loading branch information
Jordan Hall committed Jul 26, 2023
1 parent 4509d07 commit f23ebe6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"laravel/framework": "^5.5||^6.0||^7.0||^8.0||^9.0"
},
"require-dev": {
"orchestra/testbench": "~3.0",
"phpunit/phpunit": "^7.0",
"orchestra/testbench": "~5.0",
"phpunit/phpunit": "^8.0",
"php-coveralls/php-coveralls": "^2.1",
"doctrine/dbal": "^1.0||^2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/Basketable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

interface Basketable
{
public function getPrice();
public function getPrice($basketItemMeta = null);

public function getName();
}
2 changes: 1 addition & 1 deletion src/Models/BasketItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public function setQuantity(int $quantity)

public function getPrice()
{
return $this->quantity * $this->basketable->getPrice();
return $this->quantity * $this->basketable->getPrice($this->meta);
}
}
2 changes: 1 addition & 1 deletion tests/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Product extends Model implements Basketable
{
public function getPrice()
public function getPrice($basketItemMeta = null)
{
return $this->price;
}
Expand Down

0 comments on commit f23ebe6

Please sign in to comment.