<?php
/**
* Created by Elements.at New Media Solutions GmbH
*
*/
namespace Elements\Bundle\TicketShopFrameworkBundle\Ecommerce\PricingManager;
use Elements\Bundle\TicketShopFrameworkBundle\Ecommerce\PriceSystem\PackagePriceInfo;
use Pimcore\Bundle\EcommerceFrameworkBundle\PriceSystem\PriceInfoInterface;
use Pimcore\Bundle\EcommerceFrameworkBundle\PriceSystem\PriceInterface;
use Pimcore\Bundle\EcommerceFrameworkBundle\Type\Decimal;
class PriceInfo extends \Pimcore\Bundle\EcommerceFrameworkBundle\PricingManager\PriceInfo
{
/**
* @var Decimal|null
*/
protected $baseAmount;
/**
* @return PriceInfoInterface
*/
public function getOriginalPriceInfo(): PriceInfoInterface
{
return $this->priceInfo;
}
public function getOriginalPrice(): PriceInterface
{
if ($this->priceInfo instanceof PackagePriceInfo) {
return $this->priceInfo->getOriginalPrice();
}
return parent::getOriginalPrice();
}
/**
* @return Decimal|null
*/
public function getBaseAmount(): ?Decimal
{
return $this->baseAmount;
}
/**
* @param Decimal $baseAmount
*
* @return PriceInfo
*/
public function setBaseAmount(Decimal $baseAmount): PriceInfo
{
$this->baseAmount = $baseAmount;
return $this;
}
/**
* returns base price of product (without subitems prices)
*/
public function getBasePrice(): ?PriceInterface
{
$this->getPrice();
if ($this->priceInfo instanceof PackagePriceInfo) {
$price = clone $this->priceInfo->getBaseProductPrice();
} else {
$price = clone $this->priceInfo->getPrice();
}
if ($price == null) {
return null;
}
$amount = $this->getBaseAmount() ?: $this->getAmount();
$price->setGrossAmount($amount, true, true);
return $price;
}
public function getRules(bool $forceRecalc = false): array
{
$rules = parent::getRules($forceRecalc);
return $rules;
}
}