homepartyUser = $homepartyUser; //is all total $this->points = 0; $this->price = 0; $this->price_net = 0; $this->ek_price = 0; $this->ek_price_net = 0; $this->income_price = 0; $this->weight = 0; $this->shipping_weight = 0; $this->shipping_price = 0; $this->shipping_tax_rate = 0; $this->shipping_price_net = 0; $this->shipping_tax = 0; $this->calculateUserCart(); } public function calculateUserCart(){ foreach ($this->homepartyUser->homeparty_user_order_items as $order_item) { $this->points += $order_item->getTotalPoints(); $this->price += $order_item->getTotalPrice(); $this->price_net += $order_item->geTotalPriceNet(); $this->ek_price += $order_item->geTotalEKPrice(); $this->ek_price_net += $order_item->geTotalEKPriceNet(); $this->income_price += $order_item->geTotalIncomePrice(); $this->weight += ($order_item->product->weight * $order_item->qty); } } public function getFormattedPoints() { return formatNumber($this->points, 0); } public function getFormattedPrice() { return formatNumber($this->price); } public function getFormattedPriceNet() { return formatNumber($this->price_net); } public function getFormattedEkPrice() { return formatNumber($this->ek_price); } public function getFormattedEkPriceWithout() { return formatNumber($this->ek_price - $this->shipping_price); } public function getFormattedIncomePrice() { return formatNumber($this->income_price); } public function getFormattedShippingPrice() { return formatNumber($this->shipping_price); } protected function numberFormat($value, $decimals, $decimalPoint, $thousandSeperator) { if(is_null($decimals)){ $decimals = is_null(config('cart.format.decimals')) ? 2 : config('cart.format.decimals'); } if(is_null($decimalPoint)){ $decimalPoint = is_null(config('cart.format.decimal_point')) ? '.' : config('cart.format.decimal_point'); } if(is_null($thousandSeperator)){ $thousandSeperator = is_null(config('cart.format.thousand_seperator')) ? ',' : config('cart.format.thousand_seperator'); } return number_format($value, $decimals, $decimalPoint, $thousandSeperator); } public function getCurrencyByKey($key) { $rNumber = 0; if($this->homepartyUser->homeparty && $this->homepartyUser->homeparty->isPriceCurrency()){ $user_country = $this->homepartyUser->homeparty->getUserCountry(); $faktor = isset($user_country->currency_faktor) ? $user_country->currency_faktor : 1; switch ($key) { case 'ShippingPrice': $rNumber = $this->shipping_price * $faktor; break; case 'IncomePrice': $rNumber = $this->income_price * $faktor; break; case 'Price': $rNumber = $this->price * $faktor; break; case 'EkPrice': $rNumber = $this->ek_price * $faktor; break; case 'EkPriceWithout': $rNumber = ($this->ek_price - $this->shipping_price) * $faktor; break; } } return formatNumber($rNumber); } }