Skip to content

Commit

Permalink
Merge pull request #18 from vitorrgg/patch-1
Browse files Browse the repository at this point in the history
adding to total_price the additional_price when there is one
  • Loading branch information
matheusgnreis authored Jan 26, 2024
2 parents 7b575a9 + a07bbcf commit b9d43c0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions functions/routes/ecom/modules/calculate-shipping.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,22 @@ exports.post = async ({ appSdk }, req, res) => {
flags: ['correios-api']
}

// check for default configured additional/discount price
if (typeof appData.additional_price === 'number' && appData.additional_price) {
if (appData.additional_price > 0) {
shippingLine.other_additionals = [{
tag: 'additional_price',
label: 'Adicional padrão',
price: appData.additional_price
}]
} else {
// negative additional price to apply discount
shippingLine.discount -= appData.additional_price
}
// update total price
shippingLine.total_price += appData.additional_price
}

// search for discount by shipping rule
if (Array.isArray(appData.shipping_rules)) {
for (let i = 0; i < appData.shipping_rules.length; i++) {
Expand Down

0 comments on commit b9d43c0

Please sign in to comment.