Skip to content

Commit

Permalink
Merge pull request #115 from geisi/master
Browse files Browse the repository at this point in the history
Fixing InvalidArgumentException when adding buyable models
  • Loading branch information
Patrick authored Jan 18, 2021
2 parents e56adef + 40f47e8 commit f2c763e
Show file tree
Hide file tree
Showing 4 changed files with 313 additions and 148 deletions.
20 changes: 10 additions & 10 deletions src/CanBeBought.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ public function getBuyableIdentifier($options = null)
*/
public function getBuyableDescription($options = null)
{
if (property_exists($this, 'name')) {
return $this->name;
if (($name = $this->getAttribute('name'))) {
return $name;
}

if (property_exists($this, 'title')) {
return $this->title;
if (($title = $this->getAttribute('title'))) {
return $ttle;
}

if (property_exists($this, 'description')) {
return $this->description;
if (($description = $this->getAttribute('description'))) {
return $description;
}
}

Expand All @@ -41,8 +41,8 @@ public function getBuyableDescription($options = null)
*/
public function getBuyablePrice($options = null)
{
if (property_exists($this, 'price')) {
return $this->price;
if (($price = $this->getAttribute('price'))) {
return $price;
}
}

Expand All @@ -53,8 +53,8 @@ public function getBuyablePrice($options = null)
*/
public function getBuyableWeight($options = null)
{
if (property_exists($this, 'weight')) {
return $this->weight;
if (($weight = $this->getAttribute('weight'))) {
return $weight;
}

return 0;
Expand Down
Loading

0 comments on commit f2c763e

Please sign in to comment.