This reverts commit 5d117a0acd.
This commit is contained in:
Patrick Henninger
2019-01-09 12:22:25 +01:00
parent 13238f9883
commit 55f1c4617f
7 changed files with 21 additions and 211 deletions

View File

@@ -43,13 +43,6 @@ class CartItem implements Arrayable, Jsonable
*/
public $price;
/**
* The weight of the product.
*
* @var float
*/
public $weight;
/**
* The options for this cart item.
*
@@ -86,7 +79,7 @@ class CartItem implements Arrayable, Jsonable
* @param float $price
* @param array $options
*/
public function __construct($id, $name, $price, $weight = 0, array $options = [])
public function __construct($id, $name, $price, array $options = [])
{
if(empty($id)) {
throw new \InvalidArgumentException('Please supply a valid identifier.');
@@ -101,7 +94,6 @@ class CartItem implements Arrayable, Jsonable
$this->id = $id;
$this->name = $name;
$this->price = floatval($price);
$this->weight = floatval($weight);
$this->options = new CartItemOptions($options);
$this->rowId = $this->generateRowId($id, $options);
}
@@ -225,19 +217,6 @@ class CartItem implements Arrayable, Jsonable
return $this->numberFormat($this->discountTotal, $decimals, $decimalPoint, $thousandSeperator);
}
/**
* Returns the formatted weight.
*
* @param int $decimals
* @param string $decimalPoint
* @param string $thousandSeperator
* @return string
*/
public function weight($decimals = null, $decimalPoint = null, $thousandSeperator = null)
{
return $this->numberFormat($this->weight, $decimals, $decimalPoint, $thousandSeperator);
}
/**
* Set the quantity for this cart item.
*
@@ -277,7 +256,6 @@ class CartItem implements Arrayable, Jsonable
$this->qty = array_get($attributes, 'qty', $this->qty);
$this->name = array_get($attributes, 'name', $this->name);
$this->price = array_get($attributes, 'price', $this->price);
$this->weight = array_get($attributes, 'weight', $this->weight);
$this->priceTax = $this->price + $this->tax;
$this->options = new CartItemOptions(array_get($attributes, 'options', $this->options));
@@ -367,10 +345,6 @@ class CartItem implements Arrayable, Jsonable
return $this->discount * $this->qty;
}
if($attribute === 'weightTotal') {
return $this->qty * $this->weight;
}
if($attribute === 'model' && isset($this->associatedModel)) {
return with(new $this->associatedModel)->find($this->id);
}
@@ -387,7 +361,7 @@ class CartItem implements Arrayable, Jsonable
*/
public static function fromBuyable(Buyable $item, array $options = [])
{
return new self($item->getBuyableIdentifier($options), $item->getBuyableDescription($options), $item->getBuyablePrice($options), $item->getBuyableWeight($options), $options);
return new self($item->getBuyableIdentifier($options), $item->getBuyableDescription($options), $item->getBuyablePrice($options), $options);
}
/**
@@ -412,9 +386,9 @@ class CartItem implements Arrayable, Jsonable
* @param array $options
* @return \Gloudemans\Shoppingcart\CartItem
*/
public static function fromAttributes($id, $name, $price, $weight = 0, array $options = [])
public static function fromAttributes($id, $name, $price, array $options = [])
{
return new self($id, $name, $price, $weight, $options);
return new self($id, $name, $price, $options);
}
/**
@@ -444,7 +418,6 @@ class CartItem implements Arrayable, Jsonable
'name' => $this->name,
'qty' => $this->qty,
'price' => $this->price,
'weight' => $this->weight,
'options' => $this->options->toArray(),
'discount' => $this->discount,
'tax' => $this->tax,