English
price-service.batchAddAfter.parseData
About 192 wordsLess than 1 minute
2026-05-08
Execution Timing
After batch-added data is prepared and before calling the pricing API, data fields can be modified
Parameters
| Parameter | Description | Type |
|---|---|---|
| data | Object data to add | Array/Object |
| lookupDatas | Corresponding metadata | Array/Object |
| param | Other parameter object | Object |
Return Result
| Parameter | Description | Type |
|---|---|---|
| data | Processed object data | Array/Object |
Notes
- This hook is triggered after batch-added data is prepared and before the pricing service runs, and can be used to preprocess data.
- Data can be formatted, transformed, or supplemented in this hook.
- The returned
datareplaces the original data and is used for subsequent pricing service processing. - If returned
datais empty or is not returned, execution continues with the original data.
Code Example
export default class Plugin {
apply() {
return [{
event: "price-service.batchAddAfter.parseData",
functional: this.parseData.bind(this)
},
];
}
async parseData(context){
let { data, lookupDatas, param } = context;
// Ensure data is in array format
let processedData = data;
// Process each data item
processedData = processedData.map(item => {
// Add or modify fields
if(!item.processedTime) {
item.processedTime = new Date().toISOString();
}
// Apply specific processing based on parameters
if(param && param.addTaxInfo) {
item.taxRate = param.defaultTaxRate || 0.13;
item.priceIncludeTax = param.priceIncludeTax || false;
}
return item;
});
return {
data: processedData,
};
}
}