![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mcoil.corals.io/app/Shop/Carts/ |
<?php namespace App\Shop\Carts; use Gloudemans\Shoppingcart\Cart; use Gloudemans\Shoppingcart\CartItem; class ShoppingCart extends Cart { public static $defaultCurrency; protected $session; protected $event; public function __construct() { $this->session = $this->getSession(); $this->event = $this->getEvents(); parent::__construct($this->session, $this->event); self::$defaultCurrency = config('cart.currency'); } public function getSession() { return app()->make('session'); } public function getEvents() { return app()->make('events'); } /** * Get the total price of the items in the cart. * * @param int $decimals * @param string $decimalPoint * @param string $thousandSeparator * @param float $shipping * @return string */ public function total($decimals = null, $decimalPoint = null, $thousandSeparator = null, $shipping = 0.00) { $content = $this->getContent(); $total = $content->reduce(function ($total, CartItem $cartItem) { return $total + ($cartItem->qty * $cartItem->priceTax); }, 0); $grandTotal = $total + $shipping; return number_format($grandTotal, $decimals, $decimalPoint, $thousandSeparator); } }