Shipping method schema for E-Commerce module.
Supports weight-based, price-based, and geographic restrictions.
Fields
name- Method name (required)slug- URL-friendly identifier (unique, auto-generated)description- Method descriptionprice- Shipping costfree_above_amount- Free shipping thresholdmin_weight_grams,max_weight_grams- Weight limitsmin_order_amount,max_order_amount- Order amount limitscountries- Allowed countries (empty = all)excluded_countries- Excluded countriesactive- Enabled/disabledposition- Sort orderestimated_days_min,estimated_days_max- Delivery estimatetracking_supported- Tracking available
Summary
Functions
Returns true if method is active.
Checks if this method is available for given cart parameters.
Calculates shipping cost for given subtotal. Returns 0 if free shipping threshold is met.
Changeset for shipping method creation and updates.
Returns estimated delivery string.
Checks if shipping is free for the given subtotal.
Functions
Returns true if method is active.
Checks if this method is available for given cart parameters.
Examples
iex> available_for?(method, %{weight_grams: 500, subtotal: Decimal.new("50"), country: "EE"})
true
Calculates shipping cost for given subtotal. Returns 0 if free shipping threshold is met.
Changeset for shipping method creation and updates.
Returns estimated delivery string.
Examples
iex> delivery_estimate(%ShippingMethod{estimated_days_min: 3, estimated_days_max: 5})
"3-5 days"
iex> delivery_estimate(%ShippingMethod{estimated_days_min: 1, estimated_days_max: 1})
"1 day"
Checks if shipping is free for the given subtotal.