PhoenixKitEcommerce.ShippingMethod (PhoenixKitEcommerce v0.5.11)

Copy Markdown View Source

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 description
  • price - Shipping cost
  • free_above_amount - Free shipping threshold
  • min_weight_grams, max_weight_grams - Weight limits
  • min_order_amount, max_order_amount - Order amount limits
  • countries - Allowed countries (empty = all)
  • excluded_countries - Excluded countries
  • active - Enabled/disabled
  • position - Sort order
  • estimated_days_min, estimated_days_max - Delivery estimate
  • tracking_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.

Types

t()

@type t() :: %PhoenixKitEcommerce.ShippingMethod{
  __meta__: term(),
  active: term(),
  countries: term(),
  currency: term(),
  description: term(),
  estimated_days_max: term(),
  estimated_days_min: term(),
  excluded_countries: term(),
  free_above_amount: term(),
  inserted_at: term(),
  max_order_amount: term(),
  max_weight_grams: term(),
  metadata: term(),
  min_order_amount: term(),
  min_weight_grams: term(),
  name: term(),
  position: term(),
  price: term(),
  slug: term(),
  tracking_supported: term(),
  updated_at: term(),
  uuid: term()
}

Functions

active?(arg1)

Returns true if method is active.

available_for?(method, params)

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

calculate_cost(shipping_method, subtotal)

Calculates shipping cost for given subtotal. Returns 0 if free shipping threshold is met.

changeset(method, attrs)

Changeset for shipping method creation and updates.

delivery_estimate(shipping_method)

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"

free_for?(shipping_method, subtotal)

Checks if shipping is free for the given subtotal.