-
Currently in cart, we have shipping fee and tax. In my case, I need to add one more fee additional named “services fee” based on the number of products in the cart. Could someone suggest an approach to implement it in MedusaJS? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
any update?? Quang, we are implementing it too |
Beta Was this translation helpful? Give feedback.
-
Hi @quang-ng - adding custom line items to a cart is possible. You can use this option to support something like a fee. An option would be to have a custom endpoint along the lines of const feeInclTax = await yourLogicToCalculateFee(cartId)
await lineItemService.create({
cart_id: cartId,
title: "Fees",
has_shipping: true,
allow_discounts: false,
unit_price: feeInclTax,
quantity: 1,
includes_tax: true
}) The endpoint could then be called from the checkout flow at a suitable time to display the final total to the customer. You may also want to consider adding your own CartCompletionStrategy to add a validation step that ensures the fees have been added to the cart before the order gets processed. Hope this helps :) |
Beta Was this translation helpful? Give feedback.
Thank you very much for your reply. Let me implement and update the result.