<?php

namespace App\Models\Ecommerce\Product\Order\Concerns;

trait HasPayments
{
    /**
     * Total price for order
     */
    public function total(): float
    {
        return $this->items->sum('total');
    }

    /**
     * Return total order with shipping.
     */
    public function fullPriceWithShipping(): string
    {
        return floatval($this->total()) + floatval($this->shippingPrice()) + floatval($this->additional_tax);
    }

    /**
     * Formatted payment type
     */
    public function formattedPaymentType(): string
    {
        return $this->paymentType?->name;
    }
}
