mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-11 18:54:33 +00:00
63 lines
1.3 KiB
PHP
63 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Gloudemans\Shoppingcart;
|
|
|
|
trait CanBeBought
|
|
{
|
|
/**
|
|
* Get the identifier of the Buyable item.
|
|
*
|
|
* @return int|string
|
|
*/
|
|
public function getBuyableIdentifier($options = null)
|
|
{
|
|
return method_exists($this, 'getKey') ? $this->getKey() : $this->id;
|
|
}
|
|
|
|
/**
|
|
* Get the name, title or description of the Buyable item.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getBuyableDescription($options = null)
|
|
{
|
|
if (($name = $this->getAttribute('name'))) {
|
|
return $name;
|
|
}
|
|
|
|
if (($title = $this->getAttribute('title'))) {
|
|
return $ttle;
|
|
}
|
|
|
|
if (($description = $this->getAttribute('description'))) {
|
|
return $description;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the price of the Buyable item.
|
|
*
|
|
* @return float
|
|
*/
|
|
public function getBuyablePrice($options = null)
|
|
{
|
|
if (($price = $this->getAttribute('price'))) {
|
|
return $price;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the weight of the Buyable item.
|
|
*
|
|
* @return float
|
|
*/
|
|
public function getBuyableWeight($options = null)
|
|
{
|
|
if (($weight = $this->getAttribute('weight'))) {
|
|
return $weight;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|