Cart\Cart::totalExcludingTax PHP Method

totalExcludingTax() public method

Get the cart total excluding tax.
public totalExcludingTax ( ) : float
return float
    public function totalExcludingTax()
    {
        return (double) array_sum(array_map(function (CartItem $item) {
            return $item->getTotalPriceExcludingTax();
        }, $this->items));
    }

Usage Example

Beispiel #1
0
 public function calculateDiscount(Coupon $coupon, Cart $cart)
 {
     $config = $coupon->getConfig();
     $over = $config['over'];
     $percent = $config['percent'];
     $total = $cart->totalExcludingTax();
     if ($total > $over) {
         $discount = $total - $total * (1 - $percent / 100);
         $cart->setDiscount($discount);
     }
 }