
Shipping Rate Calculator
- 69 installs
- 41 repo stars
- Updated March 13, 2026
- finsilabs/awesome-ecommerce-skills
Show real-time shipping rates from UPS, FedEx, USPS, and DHL at checkout by integrating with each carrier's rate API.
About
Integrates UPS, FedEx, USPS, and DHL rate APIs to display real-time shipping costs at checkout. A developer uses it to quote accurate live shipping rates instead of flat fees.
- Live rates from UPS, FedEx, USPS, and DHL
- Carrier rate-API integration at checkout
Shipping Rate Calculator by the numbers
- 69 all-time installs (skills.sh)
- Ranked #3,093 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
- Data as of Aug 3, 2026 (Skillselion catalog sync)
npx skills add https://github.com/finsilabs/awesome-ecommerce-skills --skill shipping-rate-calculatorAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 69 |
|---|---|
| repo stars | ★ 41 |
| Last updated | March 13, 2026 |
| Repository | finsilabs/awesome-ecommerce-skills ↗ |
What it does
Show real-time shipping rates from UPS, FedEx, USPS, and DHL at checkout by integrating with each carrier's rate API.
Files
Shipping Rate Calculator
Overview
Showing real-time shipping rates at checkout — from UPS, FedEx, USPS, DHL — lets customers choose their preferred service and prevents you from under- or overcharging for shipping. Every major platform supports carrier-calculated rates natively or through apps, and a multi-carrier rate shopping tool can save you 15–40% on shipping costs by automatically selecting the cheapest option.
When to Use This Skill
- When adding real-time carrier rate quotes to checkout
- When building a multi-carrier shipping rate comparison feature
- When implementing free shipping thresholds or tiered flat-rate shipping
- When you need to calculate dimensional weight for accurate carrier pricing
- When setting up shipping zones and rate tables for international shipping
Core Instructions
Step 1: Determine your platform and choose the right shipping rate tool
| Platform | Recommended Tool | Why |
|---|---|---|
| Shopify | Shopify Shipping (built-in) or Easyship / ShipStation for rate shopping | Shopify Shipping gives discounted USPS, UPS, DHL rates; Easyship adds 250+ carrier options and rate shopping |
| WooCommerce | WooCommerce Shipping (USPS/DHL) + Table Rate Shipping for custom rules | WooCommerce Shipping handles basic carrier rates; Table Rate Shipping adds weight/zone-based rule tables |
| BigCommerce | ShipperHQ or Easyship | ShipperHQ is the most powerful rate management tool for BigCommerce with dimensional rate calculation |
| Custom / Headless | EasyPost or Shippo as a carrier meta-API | Both aggregate UPS, FedEx, USPS, DHL into a single API call — far simpler than integrating each carrier directly |
Step 2: Set up carrier-calculated rates
Shopify
Shopify Shipping (built-in, free, recommended starting point):
1. Go to Settings → Shipping and delivery → Manage rates 2. Under your domestic zone, click Add rate 3. Select Use carrier or app to calculate rates 4. Choose from: USPS, UPS, DHL Express 5. Check the services you want to offer (e.g., USPS Priority Mail, USPS Ground Advantage, UPS Ground, UPS 2nd Day Air) 6. Optionally add a markup or discount percentage on top of carrier rates (useful to offset packing material costs) 7. Save — rates will now appear dynamically at checkout based on the order's actual weight and destination
For more carrier options (FedEx, regional carriers, international): 1. Install Easyship or ShipStation from the Shopify App Store 2. Both integrate as Shopify "carrier-calculated shipping" providers and appear natively at checkout 3. Easyship's free tier shows live rates from 50+ carriers at checkout 4. Note: Carrier-calculated rates at checkout require Shopify's Advanced plan ($299/mo) or higher, OR purchasing the carrier-calculated shipping add-on ($20/month on lower plans)
For flat-rate and free-shipping rules:
- In Shopify Shipping, you can create flat-rate options ($5.99 standard shipping, $14.99 express) in addition to or instead of carrier-calculated rates
- Combine with a free shipping threshold: add a free shipping rate with a minimum order condition (see @free-shipping-thresholds skill)
WooCommerce
WooCommerce Shipping (USPS + DHL, free): 1. Install the WooCommerce Shipping plugin (free, by WooCommerce) 2. Go to WooCommerce → Settings → Shipping → Add shipping zone for each region 3. Under each zone, click Add shipping method → select USPS or DHL Express 4. Configure which services to display at checkout (Priority Mail, Ground Advantage, etc.) 5. Add your package dimensions and weights to products for accurate rate calculation
WooCommerce Table Rate Shipping (for complex rules, e.g., weight tiers, custom zones): 1. Purchase the WooCommerce Table Rate Shipping extension from WooCommerce.com 2. Create rate tables: e.g., 0–1lb = $4.99, 1–5lb = $7.99, 5–20lb = $12.99 3. Create separate tables for domestic vs. international zones
ShipStation for WooCommerce (multi-carrier rate shopping): 1. Install the ShipStation for WooCommerce plugin 2. ShipStation can be configured to use your negotiated carrier rates and display them at checkout via WooCommerce's shipping method API 3. Note: ShipStation shows rates in your ShipStation dashboard, not always directly at customer checkout — check ShipStation documentation for the specific WooCommerce checkout rate display feature
BigCommerce
ShipperHQ (most powerful option for BigCommerce): 1. Install ShipperHQ from the BigCommerce App Marketplace 2. Connect your UPS, FedEx, USPS, DHL accounts to ShipperHQ (or use ShipperHQ's built-in carrier accounts) 3. ShipperHQ handles dimensional weight calculations automatically based on your product dimensions 4. Configure rate shopping rules: "Show cheapest option", "Show all options", or "Show cheapest per delivery speed tier" 5. Set markup rules: +$2 per shipment for handling, or -15% discount on all FedEx rates
BigCommerce built-in real-time rates: 1. Go to Store Setup → Shipping → Add a shipping zone 2. Under the zone, add a real-time carrier method (UPS, FedEx, USPS via Endicia) 3. Enter your carrier account credentials 4. BigCommerce will display live carrier rates at checkout
Custom / Headless
Use EasyPost or Shippo as a meta-API to get rates from all carriers in one call — far simpler than integrating UPS, FedEx, USPS, and DHL separately:
import EasyPost from '@easypost/api';
const easypost = new EasyPost(process.env.EASYPOST_API_KEY);
// Get multi-carrier rates for a shipment
async function getShippingRates(params: {
originZip: string;
destinationZip: string;
destinationCountry: string;
weightOz: number;
lengthIn: number;
widthIn: number;
heightIn: number;
}): Promise<{ carrier: string; service: string; rateCents: number; estimatedDays: number }[]> {
const shipment = await easypost.Shipment.create({
from_address: {
zip: params.originZip,
country: 'US',
},
to_address: {
zip: params.destinationZip,
country: params.destinationCountry,
},
parcel: {
length: params.lengthIn,
width: params.widthIn,
height: params.heightIn,
weight: params.weightOz, // EasyPost uses oz
},
});
return shipment.rates.map(rate => ({
carrier: rate.carrier,
service: `${rate.carrier} ${rate.service}`,
rateCents: Math.round(parseFloat(rate.rate) * 100),
estimatedDays: rate.est_delivery_days ?? 5,
})).sort((a, b) => a.rateCents - b.rateCents);
}
// Apply store-level rules on top of carrier rates
function applyShippingRules(params: {
carrierRates: { carrier: string; service: string; rateCents: number; estimatedDays: number }[];
cartSubtotalCents: number;
freeShippingThresholdCents: number;
}): { label: string; rateCents: number; estimatedDays: number }[] {
const rates = [...params.carrierRates];
// Add free shipping option if eligible
if (params.cartSubtotalCents >= params.freeShippingThresholdCents) {
rates.unshift({ carrier: 'store', service: 'Free Shipping', rateCents: 0, estimatedDays: 7 });
}
// Show max 3 options to avoid choice paralysis:
// 1. Free (if available)
// 2. Cheapest paid option
// 3. Fastest guaranteed option
const freeOption = rates.find(r => r.rateCents === 0);
const cheapestPaid = rates.filter(r => r.rateCents > 0).sort((a, b) => a.rateCents - b.rateCents)[0];
const fastest = rates.filter(r => r.estimatedDays <= 2).sort((a, b) => a.estimatedDays - b.estimatedDays)[0];
return [freeOption, cheapestPaid, fastest]
.filter(Boolean)
.filter((r, i, arr) => arr.findIndex(x => x?.service === r?.service) === i) // deduplicate
.map(r => ({ label: r!.service, rateCents: r!.rateCents, estimatedDays: r!.estimatedDays }));
}Step 3: Configure dimensional weight calculation
Carriers charge based on the greater of actual weight vs. dimensional weight. Always configure this.
Shopify:
- Enter package dimensions on each product variant (Products → [Product] → Shipping section)
- Shopify automatically calculates dimensional weight when computing carrier rates
WooCommerce:
- Enter dimensions in the WooCommerce product Shipping tab (length, width, height in inches/cm)
- The WooCommerce Shipping plugin uses these dimensions for DHL and USPS dimensional rates
ShipperHQ:
- ShipperHQ has advanced dimensional weight packing simulation — it determines how multiple items pack into your actual box sizes and calculates the rate based on the packed box, not just the sum of item weights
Manual check for dimensional weight:
- DIM factor (US domestic): 139 cubic inches per pound
- Formula: (L × W × H) / 139 = DIM weight in lbs
- If DIM weight > actual weight, carrier charges DIM weight
Step 4: Display the right number of options at checkout
Too many shipping options cause checkout abandonment. Best practice:
1. Cheapest option — always show this (often "Ground" or "Standard") 2. Free shipping — if the cart qualifies, show it prominently at the top 3. Fastest option — 1-day or 2-day air for customers who need speed
Remove everything in between (3-day, 5-day, etc.) — customers don't need 6 options.
In ShipperHQ: use "Rate Filters" to show only specific service levels. In Easyship: configure "Checkout Rules" to limit displayed options.
Best Practices
- Always set carrier API timeouts — carrier rate APIs can take 2–5 seconds; show cached or flat-rate fallbacks if they don't respond in time
- Validate addresses before requesting rates — invalid addresses cause rate errors and checkout failures; most carriers offer address validation APIs (Shippo has one built in)
- Round up package weights — carriers round up to the next whole pound/kg; do the same in your rate calculation to avoid showing a lower rate than the customer will actually be charged
- Offer free shipping as a separate option, not by discounting a carrier rate — present it as "Free Shipping (5–7 days)" rather than modifying a carrier's listed rate
- Recalculate rates when the cart changes — re-fetch rates when items are added, quantities change, or the shipping address is updated
Common Pitfalls
| Problem | Solution |
|---|---|
| Carrier API returns no rates for a valid address | Check if the address is a PO Box (UPS/FedEx don't deliver to PO Boxes); fall back to USPS for PO Boxes |
| Checkout shows lower shipping cost than order total charged | Recalculate the final shipping rate in your order confirmation logic, not just at cart; rates can change between cart and checkout |
| Large light items get expensive rates | Enable dimensional weight calculation; most carriers use DIM weight for large boxes — ShipperHQ handles this automatically |
| Rate requests make checkout slow (3+ seconds) | Use a carrier aggregator (EasyPost/Shippo) instead of individual carrier APIs; aggregate has better response times |
Related Skills
- @free-shipping-thresholds
- @international-shipping
- @order-fulfillment-workflow
- @checkout-flow-optimization
- @dropshipping-integration
{
"context": "Tests whether the agent correctly implements dimensional weight calculation using the specified DIM factors (139 for domestic/imperial, 5000 for metric), always charges the greater of actual vs dimensional weight with ceiling applied, and properly normalizes weight units.",
"type": "weighted_checklist",
"checklist": [
{
"name": "DIM factor 139 used",
"max_score": 12,
"description": "Uses the value 139 as the DIM factor for imperial (cubic inches to pounds) calculations"
},
{
"name": "DIM factor 5000 used",
"max_score": 12,
"description": "Uses the value 5000 as the DIM factor for metric (cubic cm to kg) calculations"
},
{
"name": "Max of actual vs dim weight",
"max_score": 12,
"description": "Returns the greater of actual weight vs dimensional weight (uses Math.max or equivalent comparison)"
},
{
"name": "Ceiling on dim weight",
"max_score": 10,
"description": "Applies Math.ceil (or equivalent ceiling function) to the dimensional weight before comparison"
},
{
"name": "oz conversion correct",
"max_score": 8,
"description": "Converts ounces to pounds by dividing by 16"
},
{
"name": "g conversion correct",
"max_score": 8,
"description": "Converts grams to pounds by dividing by 453.592 (or equivalent accurate conversion)"
},
{
"name": "kg conversion correct",
"max_score": 8,
"description": "Converts kilograms to pounds by multiplying by 2.20462 (or equivalent accurate conversion)"
},
{
"name": "Package interface defined",
"max_score": 10,
"description": "Package interface includes weight with value+unit (oz|lb|g|kg) and dimensions with length/width/height+unit (in|cm)"
},
{
"name": "Imperial vs metric branching",
"max_score": 10,
"description": "Calculation branches on dimensions.unit ('in' vs 'cm') to select the appropriate DIM factor"
},
{
"name": "Result in pounds",
"max_score": 10,
"description": "The final billable weight result is expressed in pounds (not kg or oz)"
}
]
}
Shipping Weight Calculator Module
Problem/Feature Description
A mid-sized e-commerce company has been losing money on shipping large, lightweight items — bulky foam packaging and oversized gift boxes are costing them significantly more at the carrier counter than what they quoted customers. Their current system only uses the actual scale weight, leading to consistent undercharges.
The engineering team needs a TypeScript utility module that correctly determines the billable weight for any shipment. Carriers charge based on whichever is greater: the actual weight or the dimensional (volumetric) weight — and they use specific divisors for imperial vs metric measurements. The module also needs to reliably normalize package weights from any unit into a common format for downstream processing.
Output Specification
Write a TypeScript file shipping-weight.ts that exports:
- A
calculateBillableWeight(pkg: Package)function that returns the billable weight in pounds - A
normalizeWeightToLbs(weight: Package['weight'])helper function - The
Packageinterface (or import-compatible type definitions)
Include a short README.md documenting the DIM factors used and how dimensional weight works, so other engineers understand the business logic.
Write a second file examples.ts that demonstrates calling calculateBillableWeight with at least 3 different packages (mix of imperial and metric dimensions, varying actual vs dimensional weight scenarios) and logs the results.
{
"context": "Tests whether the agent builds the rate engine with parallel fetching using Promise.allSettled, a 5-second per-carrier timeout, 15-minute in-memory caching, flat-rate fallback on total failure, and shows only 2-3 rate options to users.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Promise.allSettled used",
"max_score": 12,
"description": "Uses Promise.allSettled (not Promise.all) to fetch rates from all carriers concurrently, so individual failures don't abort the whole request"
},
{
"name": "5-second timeout per carrier",
"max_score": 12,
"description": "Each carrier call is wrapped in a Promise.race with a timeout that rejects after 5000ms (5 seconds)"
},
{
"name": "15-minute cache TTL",
"max_score": 10,
"description": "Cached rates expire after 15 minutes (900000ms or 15 * 60 * 1000)"
},
{
"name": "Cache key includes origin+dest+weight",
"max_score": 8,
"description": "The cache key is derived from origin postal code, destination postal code/country, and package weight"
},
{
"name": "Flat-rate fallback on failure",
"max_score": 12,
"description": "When all carrier API calls fail or time out, the engine returns at least one flat-rate option instead of an empty array or throwing an error"
},
{
"name": "Rates sorted ascending",
"max_score": 8,
"description": "The returned rates array is sorted by rate (price) in ascending order"
},
{
"name": "At most 3 options shown",
"max_score": 10,
"description": "The final rates presented to callers include at most 3 options (cheapest free, cheapest paid, fastest guaranteed)"
},
{
"name": "Fastest uses estimatedDays<=2",
"max_score": 8,
"description": "The 'fastest' option selection criterion checks estimatedDays <= 2 AND guaranteed === true"
},
{
"name": "registerCarrier method",
"max_score": 10,
"description": "Engine exposes a registerCarrier(adapter: CarrierAdapter) method for adding carriers"
},
{
"name": "CarrierAdapter interface",
"max_score": 10,
"description": "CarrierAdapter interface defines name (string) and getRates(request: ShipmentRequest): Promise<ShippingRate[]>"
}
]
}
Checkout Shipping Rate Engine
Problem/Feature Description
A growing online retailer is struggling with slow checkout performance and occasional complete failures when carrier APIs go down. Currently their checkout page fetches shipping rates sequentially from UPS, FedEx, and USPS — when any one of them is slow or offline, customers see a spinning loader for 15+ seconds or an error message with no shipping options at all. Cart abandonment has increased significantly.
The team needs a robust ShippingRateEngine class in TypeScript that aggregates rates across multiple carrier adapters in a resilient way. It should be fast even when some carriers are sluggish, serve previously-fetched results when appropriate, and always give customers something useful to choose from — even when all live carrier APIs fail. The checkout team wants to show customers the most relevant options without overwhelming them with choices.
Output Specification
Produce a TypeScript file rate-engine.ts containing:
- The
ShippingRateEngineclass withregisterCarrier()andgetRates()methods - All required TypeScript interfaces (
ShipmentRequest,ShippingRate,CarrierAdapter,Address,Package)
Also produce a rate-engine.test.ts file that demonstrates the engine's resilience and performance characteristics using mock carrier adapters — including scenarios where carriers behave differently (fast, slow, or failing entirely). Log results to the console so behavior is visible in output.
{
"context": "Tests whether the agent implements the ShippingRule interface with correct types and conditions, uses 'store'/'free' and 'store'/'flat' identifiers for store-generated rates, implements zone-based rate table with specific domestic/canada/international zones and weight buckets, and stores all monetary values in cents.",
"type": "weighted_checklist",
"checklist": [
{
"name": "ShippingRule type union",
"max_score": 8,
"description": "ShippingRule interface type field accepts exactly 'flat_rate' | 'free_shipping' | 'tiered_rate'"
},
{
"name": "Conditions in cents",
"max_score": 8,
"description": "ShippingRule conditions.minOrderTotal is in cents (e.g., free shipping threshold stored as integer cents, not dollars)"
},
{
"name": "Carrier 'store' for custom rates",
"max_score": 10,
"description": "Free shipping and flat-rate entries added by applyShippingRules use carrier: 'store'"
},
{
"name": "Service 'free' for free shipping",
"max_score": 8,
"description": "Free shipping entries use service: 'free'"
},
{
"name": "Service 'flat' for flat rate",
"max_score": 8,
"description": "Flat rate entries use service: 'flat'"
},
{
"name": "Three zones defined",
"max_score": 10,
"description": "Zone rate table includes exactly three zones: 'domestic' (US), 'canada' (CA), and 'international' for all other countries"
},
{
"name": "Four weight buckets",
"max_score": 10,
"description": "Zone rate table uses four weight buckets: '0-1lb', '1-5lb', '5-10lb', '10-20lb'"
},
{
"name": "Zone rates in cents",
"max_score": 10,
"description": "All rate values in the zone rate table are stored as integers in cents (e.g. 599, 899, not 5.99, 8.99)"
},
{
"name": "Combined rates sorted",
"max_score": 8,
"description": "applyShippingRules returns the combined list of carrier and store rates sorted by rate ascending"
},
{
"name": "Country condition check",
"max_score": 10,
"description": "applyShippingRules checks rule.conditions.countries (if set) against destination.country before applying the rule"
},
{
"name": "Weight condition check",
"max_score": 10,
"description": "applyShippingRules checks rule.conditions.maxOrderWeight (if set) against totalWeight before applying the rule"
}
]
}
Store Shipping Rules and Zone Pricing Module
Problem/Feature Description
A specialty outdoor retailer ships products across the US, Canada, and internationally. Their current shipping system charges every customer the same flat rate regardless of destination or order size, causing them to lose money on heavy international orders and frustrate domestic customers who expect free shipping after spending over a certain amount.
The product team wants a configurable shipping rules module that can apply store-defined promotions (free shipping above a threshold, flat-rate domestic options) on top of carrier-quoted rates, and also support a fallback rate table based on destination zone and package weight when carrier APIs are unavailable. The module needs to handle the full mix: carrier rates combined with store rules, filtered appropriately by country and order weight, and presented back in a consistent format.
Output Specification
Write a TypeScript file shipping-rules.ts that exports:
- The
ShippingRuleinterface - An
applyShippingRules()function that takes carrier rates, an array of rules, order total, total weight, and destination address, and returns a combined sorted list of all applicable rates - A
getZoneRate()function implementing a three-zone rate table (domestic US, Canada, international) with weight buckets - A
getZone()helper andgetWeightBucket()helper
Write a demo.ts script that creates a sample set of shipping rules (at least one free shipping rule with a minimum order total, one flat rate rule, and one zone-based rate lookup), runs them against two different scenarios (one domestic order above the free-shipping threshold, one international order), and prints the resulting rate options for each scenario.
{
"name": "finsi/shipping-rate-calculator",
"version": "0.1.0",
"summary": "Real-time rate calculation with carrier APIs (UPS, FedEx, USPS, DHL)",
"skills": {
"shipping-rate-calculator": {
"path": "SKILL.md"
}
}
}