E-Commerce Framework Price Object/Signature Changes
Following changes might need to be considered:
-
Price objects (
IPrice
) now use a value object instead of floats to represent prices. All calls toget*Amount()
,set*Amount()
and all custom calculations need to be updated to work with theDecimal
value object. -
Added PHP 7 type hints to interfaces where applicable, especially regarding pricing. You might need to update your implementations to match updated interface definitions. This mainly affects return types of interfaces (e.g. a
PriceInfo
is now forced to return aIPrice
object forgetTotalPrice()
where it could benull
previously) and anything working with price amounts (as theDecimal
value object is used now instead of floats).
If you implement any of the following classes/interfaces in your project, please check they match the new framework definition (see https://github.com/pimcore/pimcore/pull/1701):-
CartManager/AbstractCartItem
- changed:
-
public function getPrice(): IPrice
-
public function getPriceInfo(): IPriceInfo
-
public function getTotalPrice(): IPrice
-
- changed:
-
CartManager/CartPriceCalculator
- changed:
-
protected function getDefaultPriceObject(Decimal $amount, Currency $currency): IPrice
-
public function getGrandTotal(): IPrice
-
public function getPriceModifications(): array
-
public function getSubTotal(): IPrice
-
public function getModificators(): array
-
- changed:
-
CartManager/CartPriceModificator/IDiscount
- changed:
-
public function setAmount(Decimal $amount)
-
public function getAmount(): Decimal
-
- changed:
-
CartManager/CartPriceModificator/Discount
- changed:
-
public function setAmount(Decimal $amount)
-
public function getAmount(): Decimal
-
- changed:
-
CartManager/CartPriceModificator/IShipping
- changed:
-
public function setCharge(Decimal $charge);
-
public function getCharge(): Decimal;
-
- changed:
-
CartManager/CartPriceModificator/Shipping
- changed:
-
public function setCharge(Decimal $charge);
-
public function getCharge(): Decimal;
-
- changed:
-
CartManager/ICartItem
- changed:
-
public function getPrice(): IPrice;
-
public function getTotalPrice(): IPrice;
-
public function getPriceInfo(): IPriceInfo;
-
- changed:
-
CartManager/ICartPriceCalculator
- changed:
-
public function getSubTotal(): IPrice;
-
public function getGrandTotal(): IPrice;
-
public function getPriceModifications(): array;
-
public function getModificators(): array;
-
- changed:
-
OfferTool/DefaultService
- changed:
-
protected function priceTransformationHook(Decimal $price): Decimal
-
- changed:
-
PriceSystem/AbstractPriceInfo
- changed:
-
public function isMinPrice(): bool
-
public function setPriceSystem(IPriceSystem $priceSystem)
-
public function getPrice(): IPrice
-
public function getTotalPrice(): IPrice
-
- changed:
-
PriceSystem/AbstractPriceSystem
- changed:
-
public function getPriceInfo(ICheckoutable $product, $quantityScale = null, $products = null): IPriceInfo
-
protected function initPriceInfoInstance($quantityScale, ICheckoutable $product, $products)
-
abstract public function createPriceInfoInstance($quantityScale, ICheckoutable $product, $products);
-
- changed:
-
PriceSystem/AttributePriceInfo
- changed:
-
public function getPrice(): IPrice
-
public function getTotalPrice(): IPrice
-
- changed:
-
PriceSystem/AttributePriceSystem
- changed:
-
abstract public function createPriceInfoInstance($quantityScale, ICheckoutable $product, $products);
-
protected function calculateAmount(ICheckoutable $product, $products): Decimal
-
protected function getDefaultCurrency(): Currency
-
protected function getPriceClassInstance(Decimal $amount): IPrice
-
- changed:
-
PriceSystem/CachingPriceSystem
- changed:
-
public function getPriceInfo(ICheckoutable $product, $quantityScale = 1, $products = null): IPriceInfo
-
- changed:
-
PriceSystem/IPrice
- changed:
-
public function getAmount(): Decimal;
-
public function getCurrency(): Currency;
-
public function isMinPrice(): bool;
-
public function setAmount(Decimal $amount, string $priceMode = self::PRICE_MODE_GROSS, bool $recalc = false);
-
public function getGrossAmount(): Decimal;
-
public function getNetAmount(): Decimal;
-
public function getTaxEntries(): array;
-
public function getTaxEntryCombinationMode(): string;
-
public function setGrossAmount(Decimal $grossAmount, bool $recalc = false);
-
public function setNetAmount(Decimal $netAmount, bool $recalc = false);
-
public function setTaxEntries(array $taxEntries);
-
public function setTaxEntryCombinationMode(string $taxEntryCombinationMode);
-
- changed:
-
PriceSystem/IPriceInfo
- changed:
-
public function getPrice(): IPrice
-
public function getTotalPrice(): IPrice
-
public function isMinPrice(): bool;
-
public function setPriceSystem(IPriceSystem $priceSystem);
-
- changed:
-
PriceSystem/IPriceSystem
- changed:
-
public function getPriceInfo(ICheckoutable $product, $quantityScale = null, $products = null): IPriceInfo;
-
- changed:
-
PriceSystem/LazyLoadingPriceInfo
- changed:
-
public function getPrice(): IPrice
-
- changed:
-
PriceSystem/ModificatedPrice
- changed:
-
public function __construct(Decimal $amount, Currency $currency, bool $minPrice = false, string $description = null)
-
- changed:
-
PriceSystem/Price
- changed:
-
public function __construct(Decimal $amount, Currency $currency, bool $minPrice = false)
-
public function isMinPrice(): bool
-
public function setAmount(Decimal $amount, string $priceMode = self::PRICE_MODE_GROSS, bool $recalc = false)
-
public function getAmount(): Decimal
-
public function getCurrency(): Currency
-
public function getGrossAmount(): Decimal
-
public function getNetAmount(): Decimal
-
public function getTaxEntries(): array
-
public function getTaxEntryCombinationMode(): string
-
public function setGrossAmount(Decimal $grossAmount, bool $recalc = false)
-
public function setNetAmount(Decimal $netAmount, bool $recalc = false)
-
public function setTaxEntries(array $taxEntries)
-
public function setTaxEntryCombinationMode(string $taxEntryCombinationMode)
-
protected function updateTaxes(string $calculationMode)
-
- changed:
-
PriceSystem/TaxManagement/TaxCalculationService
- changed:
-
public function updateTaxes(IPrice $price, string $calculationMode = self::CALCULATION_FROM_NET)
-
protected function calculationFromNet(IPrice $price): IPrice
-
protected function calculationFromGross(IPrice $price): IPrice
-
- changed:
-
PriceSystem/TaxManagement/TaxEntry
- changed:
-
public function __construct($percent, Decimal $amount, string $taxId = null, TaxEntryFieldcollection $entry = null)
-
public function setEntry(TaxEntryFieldcollection $entry)
-
public function getEntry(): TaxEntryFieldcollection
-
public function getAmount(): Decimal
-
public function setAmount(Decimal $amount)
-
public function setTaxId(string $taxId = null)
-
- changed:
-
PricingManager/Condition/AbstractOrder
- changed:
-
protected function getSalesAmount(IRule $rule): Decimal
-
- changed:
-
PricingManager/IPriceInfo
- changed:
-
public function getRules(bool $forceRecalc = false): array;
-
public function setAmount(Decimal $amount);
-
public function getAmount(): Decimal;
-
public function getOriginalPrice(): IPrice;
-
public function getOriginalTotalPrice(): IPrice;
-
public function getEnvironment(): IEnvironment;
-
public function hasDiscount(): bool;
-
public function getDiscount(): IPrice;
-
public function getTotalDiscount(): IPrice;
-
public function hasRulesApplied(): bool;
-
- changed:
-
PricingManager/PriceInfo
- changed:
-
public function getEnvironment(): IEnvironment
-
public function getRules(bool $forceRecalc = false): array
-
public function getPrice(): IPrice
-
public function isMinPrice(): bool
-
public function setPriceSystem(IPriceSystem $priceSystem)
-
public function setAmount(Decimal $amount);
-
public function getAmount(): Decimal;
-
public function getOriginalPrice(): IPrice;
-
public function getOriginalTotalPrice(): IPrice;
-
public function hasDiscount(): bool;
-
public function getDiscount(): IPrice;
-
public function getTotalDiscount(): IPrice;
-
public function hasRulesApplied(): bool;
-
- changed:
-