41 lines
966 B
PHP
41 lines
966 B
PHP
<?php
|
|
|
|
namespace App\Models\Ecommerce\Product\Order\Concerns;
|
|
|
|
use App\Models\Ecommerce\Product\Order\Shipping\OrderShipping;
|
|
|
|
trait HasShipping
|
|
{
|
|
/**
|
|
* Shipping price
|
|
*/
|
|
public function shippingPrice(): int
|
|
{
|
|
if ($this->shippingMethod) {
|
|
return intval($this->shipping_price) ?: $this->shippingMethod->price;
|
|
}
|
|
|
|
return intval($this->shipping_price) ?: OrderShipping::priceFor($this->shipping_method);
|
|
}
|
|
|
|
/**
|
|
* Formatted shipping method
|
|
*/
|
|
public function formattedShippingMethod(): string
|
|
{
|
|
if ($this->shippingMethod) {
|
|
return $this->shippingMethod->name;
|
|
}
|
|
|
|
return OrderShipping::formattedShippingMethod($this->shipping_method);
|
|
}
|
|
|
|
/**
|
|
* Full address for the order
|
|
*/
|
|
public function fullAddress(): string
|
|
{
|
|
return OrderShipping::fullAddress($this->region, $this->province_id, $this->customer_address);
|
|
}
|
|
}
|