...
Technical Implementation
Conceptual Code Sample
paste-code-macro | ||
---|---|---|
| ||
def price
if (productDoesNotDependOnAnother) {
/* price of the product does not depend on another product */
/* so we can calculate the price right away */
price = calculatePrice()
} else {
/* price of the product is derived from price of other/master product */
if (api.getIterationNumber() == 0) {
/* if this is first pass, then we need to wait for the related product to be calculated */
api.markItemDirty()
} else {
/* this is already second pass, so we expect the other/master product to be calculated already */
masterProductPrice = api.currentContext(skuOfTheMasterProduct)?.Price
price = calculatePriceFrom(masterProductPrice)
}
}
return price
|
The important functions here are:
...