> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: calculateAdditionalFees(options: Options, context: Context) # Method package: wixEcom # Method menu location: wixEcom --> EcomAdditionalFees --> calculateAdditionalFees # Method Link: https://dev.wix.com/docs/velo/events-service-plugins/e-commerce/service-plugins/ecom-additional-fees/calculate-additional-fees.md # Method Description: Calculates additional fees to include in the cart and checkout pages. The `calculateAdditionalFees` function calculates additional fees to appear in the cart and checkout pages of a store's site. The function is automatically called by Wix when the cart totals are calculated, or when an action is performed in the cart and/or checkout pages. For example, when an item is added to the cart, or when a shipping location is specified. ### Where to find `calculateAdditionalFees()` When you [add the Additional Fees service plugin](https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-e-commerce-stores/e-commerce-additional-fees-custom-extension.md#step-1-create-a-new-additional-fees-custom-extension), a folder is automatically added to your site. Use the `.js` file in the folder to write the code to calculate any additional fees to add to the cart or checkout. For more information on calculating your additional fees, see [Velo Tutorial: eCommerce Additional Fees Service Plugin](https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-e-commerce-stores/e-commerce-additional-fees-custom-extension.md#my-extension-namejs). # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Calculate additional fees for an order ```javascript import wixSiteBackend from 'wix-site-backend'; export const calculateAdditionalFees = async (options) => { let additionalFees = []; const feePrice = calculateWrappingFee(options.lineItems); const currency = await wixSiteBackend.generalInfo.getPaymentCurrency(); if (feePrice) { additionalFees.push({ code: 'fragile-packaging', name: 'Fragile Packaging', price: String(feePrice), taxDetails: { taxable: true } }); } return { currency, additionalFees }; }; // Check if an item is fragile. function isFragile(item) { const productName = item.productName.toLowerCase(); return productName.includes('glass') || productName.includes('ceramic'); } // Charge per fragile item. // Give away free packaging when ordering at least 5 items. function calculateWrappingFee(lineItems) { const minItemsForFreeWrapping = 5; let numFragileItems = 0; lineItems.forEach((item) => { if (isFragile(item)){ numFragileItems += item.quantity; } }); const shouldChargeFee = numFragileItems < minItemsForFreeWrapping; const price = shouldChargeFee ? numFragileItems : 0; return price; } ``` ---