# `PhoenixKitEcommerce.Import.OptionBuilder`
[🔗](https://github.com/BeamLabEU/phoenix_kit_ecommerce/blob/v0.1.8/lib/phoenix_kit_ecommerce/import/option_builder.ex#L1)

Build option values and price modifiers from Shopify variant rows.

Extracts Option1..Option10 names and values from CSV rows,
calculates base price (minimum) and price modifiers (deltas from base).

## Extended Support

- Supports Option1 through Option10 (Shopify standard)
- Accepts option_mappings for slot-based options
- Builds _option_slots structure for products using global options

# `build_extended`

Build extended options data from variant rows.

Supports Option1 through Option10 and optional slot mappings.

## Arguments

- `rows` - List of CSV row maps for a single product
- `opts` - Keyword options:
  - `:option_mappings` - List of mapping configs from ImportConfig

## Returns

Map with:
- `base_price` - Minimum variant price
- `options` - List of option data for each option found
- `option_slots` - Slot definitions if mappings provided

## Examples

    # Without mappings (standard import)
    OptionBuilder.build_extended(rows)
    # => %{
    #   base_price: Decimal.new("22.80"),
    #   options: [
    #     %{position: 1, name: "Size", values: [...], modifiers: %{...}},
    #     %{position: 2, name: "Cup Color", values: [...]},
    #     %{position: 3, name: "Liquid Color", values: [...]}
    #   ],
    #   option_slots: []
    # }

    # With mappings (slot-based import)
    mappings = [
      %{"csv_name" => "Cup Color", "slot_key" => "cup_color", "source_key" => "color"},
      %{"csv_name" => "Liquid Color", "slot_key" => "liquid_color", "source_key" => "color"}
    ]
    OptionBuilder.build_extended(rows, option_mappings: mappings)
    # => %{
    #   base_price: Decimal.new("22.80"),
    #   options: [...],
    #   option_slots: [
    #     %{slot: "cup_color", source_key: "color", label: "Cup Color", values: [...]},
    #     %{slot: "liquid_color", source_key: "color", label: "Liquid Color", values: [...]}
    #   ]
    # }

# `build_from_variants`

Build options data from variant rows (legacy format).

Returns a map with:
- base_price: minimum variant price (Decimal)
- option1_name: name of first option (e.g., "Size")
- option1_values: list of unique values for option1
- option1_modifiers: map of value => price delta from base
- option2_name: name of second option (e.g., "Color")
- option2_values: list of unique values for option2

## Examples

    OptionBuilder.build_from_variants(rows)
    # => %{
    #   base_price: Decimal.new("22.80"),
    #   option1_name: "Size",
    #   option1_values: ["4 inches (10 cm)", "5 inches (13 cm)", ...],
    #   option1_modifiers: %{"4 inches (10 cm)" => "0", "5 inches (13 cm)" => "5.00", ...},
    #   option2_name: "Color",
    #   option2_values: ["Black", "White", ...]
    # }

---

*Consult [api-reference.md](api-reference.md) for complete listing*
