Shipping Calculator

A component for calculating shipping costs based on ZIP code and product size.

Shipping Calculator

ZIP code-based shipping calculator with validation

Shipping Information

Usage

The ShippingCalculator component allows users to enter their ZIP code to calculate shipping costs. It validates the ZIP code format, determines the nearest warehouse, and calculates a shipping cost based on distance and product size.

Props

  • warehouses - Array of warehouse objects with id, name, zipCode, and location
  • selectedSize - Currently selected product size (affects shipping cost)
  • onShippingCalculated - Function called when shipping is calculated with the shipping info

Shipping Info Object

The component returns a shipping info object with the following properties:

  • warehouse - Name of the nearest warehouse
  • location - Location of the nearest warehouse
  • cost - Calculated shipping cost
  • distance - Estimated distance in miles