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

@@ -424,33 +424,6 @@ class Cart
return $this->numberFormat($this->initialFloat(), $decimals, $decimalPoint, $thousandSeperator);
}
/**
* Get the total weight of the items in the cart.
*
* @return float
*/
public function weightFloat()
{
$content = $this->getContent();
$total = $content->reduce(function ($total, CartItem $cartItem) {
return $total + ($cartItem->qty * $cartItem->weight);
}, 0);
return $total;
}
/**
* Get the total weight of the items in the cart.
*
* @param int $decimals
* @param string $decimalPoint
* @param string $thousandSeperator
* @return string
*/
public function weight($decimals = null, $decimalPoint = null, $thousandSeperator = null)
{
return $this->numberFormat($this->weightFloat(), $decimals, $decimalPoint, $thousandSeperator);
}
/**
* Search the cart content for a cart item matching the given search closure.
*
@@ -630,12 +603,12 @@ class Cart
* @param mixed $identifier Identifier of the Cart to merge with.
* @param bool $keepDiscount Keep the discount of the CartItems.
* @param bool $keepTax Keep the tax of the CartItems.
* @return bool
* @return void
*/
public function merge( $identifier, $keepDiscount = false, $keepTax = false )
{
if( ! $this->storedCartWithIdentifierExists($identifier)) {
return false;
return;
}
$stored = $this->getConnection()->table($this->getTableName())
@@ -646,8 +619,6 @@ class Cart
foreach ($storedContent as $cartItem) {
$this->addCartItem($cartItem, $keepDiscount, $keepTax);
}
return true;
}
/**

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,

View File

@@ -24,11 +24,4 @@ interface Buyable
* @return float
*/
public function getBuyablePrice($options = null);
/**
* Get the weight of the Buyable item.
*
* @return float
*/
public function getBuyableWeight($options = null);
}