<?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\OpenMarketplace\Component\Order\Entity;
use BitBag\OpenMarketplace\Component\Order\Formatter\MoneyFormatter;
use BitBag\OpenMarketplace\Component\SellerPlan\Entity\SubscriptionInterface;
use BitBag\SyliusB2BPlugin\Entity\OrderAwareTrait;
use Sylius\Component\Core\Model\Order as BaseOrder;
class Order extends BaseOrder implements OrderInterface
{
use OrderTrait {
__construct as private initializeOrderTrait;
}
use OrderAwareTrait;
private ?SubscriptionInterface $subscription = null;
public function __construct()
{
parent::__construct();
$this->initializeOrderTrait();
}
public function getSubscription(): ?SubscriptionInterface
{
return $this->subscription;
}
public function setSubscription(?SubscriptionInterface $subscription): void
{
$this->subscription = $subscription;
}
public function getStateOfLastPayment(): ?string
{
return $this->getLastPayment()?->getState();
}
public function getFormattedTotal(): string
{
$amount = $this->getTotal();
$currencyCode = $this->getCurrencyCode() ?? 'EUR';
$locale = $this->getLocaleCode();
return MoneyFormatter::format($amount, $currencyCode, $locale);
}
}