Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Darryldecode/Cart/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public function getSubTotalWithoutConditions($formatted = true)
$cart = $this->getContent();

$sum = $cart->sum(function ($item) {
return $item->getPriceSum();
return $item->getPriceSum(false);
});

return Helpers::formatValue(floatval($sum), $formatted, $this->config);
Expand Down Expand Up @@ -647,6 +647,18 @@ public function getTotalQuantity()
return $count;
}

/**
* get total quantity of items individual in the cart
*
* @return int
*/
public function getTotalQuantityIndividual()
{
$items = $this->getContent();

return $items->count();
}

/**
* get the cart
*
Expand Down
33 changes: 31 additions & 2 deletions src/Darryldecode/Cart/ItemCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public function __construct($items, $config)
*
* @return mixed|null
*/
public function getPriceSum()
public function getPriceSum($formatted = true)
{
return Helpers::formatValue($this->price * $this->quantity, $this->config['format_numbers'], $this->config);
return Helpers::formatValue($this->price * $this->quantity, $formatted, $this->config);

}

Expand Down Expand Up @@ -118,4 +118,33 @@ public function getPriceSumWithConditions($formatted = true)
{
return Helpers::formatValue($this->getPriceWithConditions(false) * $this->quantity, $formatted, $this->config);
}

/**
* get the sum of condition type
* @param string $type
* @param bool $multiple
* @param bool $formatted
* @return mixed|null
*/
public function getPriceOfCondition($type, $multiple = true, $formatted = true)
{
$zero = 0.00;
$quantity = ($multiple == true) ? $this->quantity : 1;

if ($this->hasConditions()) {
if (is_array($this->conditions)) {
foreach ($this->conditions as $condition) {
if ($condition->getType() == $type) {
$conditionValue = $condition->getValue() * $quantity;
}
}
} else {
$conditionValue = $this['conditions']->getValue() * $quantity;
}

return Helpers::formatValue($conditionValue, $formatted, $this->config);
}

return Helpers::formatValue($zero, $formatted, $this->config);
}
}