Hello,
I’m working with EspoCRM 9.x (Cloud / self-hosted) and I’ve extended the product pricing logic to also handle distributor prices.
What I did:
I’m using the standard ProductPricingTypeHandler as a base and added a second set of fields for distributor price:
unitPriceDist is calculated and stored as expected when I save the product. The problem / question
For the standard client price, when I change e.g. pricingFactor or pricingType on the Product form:
For my distributor price:
I’d like to have the same UX for distributor price – update unitPriceDist instantly in the Product edit view when one of the related fields changes.
My questions
Any hints (file paths, example code, best practice) would be greatly appreciated.
Thank you!
I’m working with EspoCRM 9.x (Cloud / self-hosted) and I’ve extended the product pricing logic to also handle distributor prices.
What I did:
I’m using the standard ProductPricingTypeHandler as a base and added a second set of fields for distributor price:
- listPriceDist (Currency)
- pricingFactorDist (Float)
- pricingTypeDist (Enum – same options as pricingType)
- unitPriceDist (Currency, result)
- I reuse the existing costPrice field.
unitPriceDist is calculated and stored as expected when I save the product. The problem / question
For the standard client price, when I change e.g. pricingFactor or pricingType on the Product form:
- unitPrice is updated live in the UI (without saving),
- so there is some front-end (JavaScript) logic that recalculates it on the fly.
For my distributor price:
- the value of unitPriceDist is only updated after save (because only PHP handler runs),
- it does not update live when I change pricingFactorDist, pricingTypeDist, etc.
I’d like to have the same UX for distributor price – update unitPriceDist instantly in the Product edit view when one of the related fields changes.
My questions
- In which JS file / view does Espo implement the live calculation for unitPrice on Product (when pricingType, listPrice, costPrice, pricingFactor change)?
- What is the recommended way to extend this to also handle:
- pricingTypeDist
- listPriceDist
- pricingFactorDist
- unitPriceDist
Any hints (file paths, example code, best practice) would be greatly appreciated.
Thank you!
