I’m trying to write plugin in Shopware6, it must add some custom values (like deposit) to Product line item. So I wrote my class
class DepositCalculatedPrice extends CalculatedPrice
{
/** @var float $deposit */
protected $deposit;
public function __construct(
float $unitPrice,
float $totalPrice,
CalculatedTaxCollection $calculatedTaxes,
CalculatedTaxCollection $calculatedTaxesNoDeposit,
TaxRuleCollection $taxRules,
int $quantity = 1,
?ReferencePrice $referencePrice = null,
?ListPrice $listPrice = null,
float $deposit = 0,
) {
parent::__construct(
$unitPrice,
$totalPrice,
$calculatedTaxes,
$taxRules,
$quantity,
$referencePrice,
$listPrice
);
$this->deposit = $deposit;
}
public function getDeposit(): float
{
return FloatComparator::cast($this->deposit);
}
}
Then I use it in my Calculator and then in my PriceProcessor. All goes well until I try to submit my order, but then Shopware6 checks field definintion classes in Checkout/Order/Aggregate/OrderLineItem/OrderLineItemDefinition.php
, and it checks Price json field against CalculatedPrice, not DepositCalculatedPrice. So is there any way to resolve it? Maybe I can use somewhere some descendant of OrderLineItemDefinition.php
? Or make it not checking field definitions?