Calculate Shipping By Id
amerta / amerta/theme/utilities/calculate-shipping-by-id / calculateShippingById
Function: calculateShippingById()
calculateShippingById(
shippingMethodId,country,city,orderSubtotal):Promise<{baseCost:number;isFree:boolean;tax:number;total:number; }>
Defined in: amerta/theme/utilities/calculate-shipping-by-id.ts:14
Calculates total shipping cost including tax by shipping method ID.
Parameters
| Parameter | Type | Description |
| ------ | ------ | ------ |
| shippingMethodId | string | The ID of the shipping method. |
| country | string | Country | The country ID or object. |
| city | string | The city name or code. |
| orderSubtotal | number | The order subtotal to check for free shipping eligibility. |
Returns
Promise<{ baseCost: number; isFree: boolean; tax: number; total: number; }>
Object containing shipping cost breakdown.
Example
const cost = await calculateShippingById("ship123", "us", "NYC", 150);