Product Configuration Wizard Development
Configurator lets a buyer assemble products to their requirements: choose processor, RAM, storage and laptop case color; select jewelry size, material and engraving; outfit a furniture set from compatible elements. Result—unique configuration with calculated final price and optional visualization.
Configurator Types
| Type | Examples | Features |
|---|---|---|
| Linear | Laptop: CPU → RAM → SSD | Each choice independent, price summed |
| Dependent | PC: motherboard → compatible CPU | Next step depends on previous |
| Visual | Kitchen, furniture, car | Image changes on selection |
| Modular | Wardrobe: width + sections + inserts | Arbitrary combinations within limits |
Data Schema
CREATE TABLE configurators (
id BIGSERIAL PRIMARY KEY,
product_id BIGINT REFERENCES products(id),
name VARCHAR(255),
base_price NUMERIC(12,2) DEFAULT 0,
image_base_url TEXT,
is_active BOOLEAN DEFAULT TRUE
);
CREATE TABLE config_groups (
id BIGSERIAL PRIMARY KEY,
configurator_id BIGINT REFERENCES configurators(id) ON DELETE CASCADE,
name VARCHAR(255) NOT NULL,
slug VARCHAR(100) NOT NULL,
type VARCHAR(20) NOT NULL, -- 'radio', 'checkbox', 'quantity', 'text'
is_required BOOLEAN DEFAULT TRUE,
sort_order SMALLINT DEFAULT 0,
depends_on_group_id BIGINT REFERENCES config_groups(id),
depends_on_option_id BIGINT
);
CREATE TABLE config_options (
id BIGSERIAL PRIMARY KEY,
group_id BIGINT REFERENCES config_groups(id) ON DELETE CASCADE,
name VARCHAR(255) NOT NULL,
sku_suffix VARCHAR(100),
price_modifier NUMERIC(12,2) DEFAULT 0,
weight_modifier INT DEFAULT 0,
image_layer VARCHAR(500),
stock INT DEFAULT 9999,
is_default BOOLEAN DEFAULT FALSE,
sort_order SMALLINT DEFAULT 0
);
CREATE TABLE config_compatibility (
id BIGSERIAL PRIMARY KEY,
option_a_id BIGINT REFERENCES config_options(id),
option_b_id BIGINT REFERENCES config_options(id),
type VARCHAR(20) NOT NULL, -- 'required', 'forbidden', 'recommended'
message TEXT
);
Backend: Price Calculation and Validation
class ConfiguratorEngine
{
public function calculate(int $configuratorId, array $selectedOptions): ConfigResult
{
$configurator = Configurator::with([
'groups.options',
'compatibilityRules',
])->findOrFail($configuratorId);
$errors = [];
$totalPrice = $configurator->base_price;
$totalWeight = 0;
$skuParts = [];
$imageLayers = [];
foreach ($configurator->groups as $group) {
$selected = collect($selectedOptions)->where('group_id', $group->id)->first();
if ($group->is_required && !$selected) {
$errors[] = "Not selected: {$group->name}";
continue;
}
if (!$selected) continue;
$option = $group->options->find($selected['option_id']);
if (!$option) {
$errors[] = "Invalid option for {$group->name}";
continue;
}
$totalPrice += $option->price_modifier;
$totalWeight += $option->weight_modifier;
if ($option->sku_suffix) $skuParts[] = $option->sku_suffix;
if ($option->image_layer) $imageLayers[] = $option->image_layer;
}
// Check compatibility
$compatErrors = $this->checkCompatibility($selectedOptions, $configurator->compatibilityRules);
$errors = array_merge($errors, $compatErrors);
return new ConfigResult(
isValid: empty($errors),
errors: $errors,
totalPrice: $totalPrice,
totalWeight: $totalWeight,
configSku: implode('-', $skuParts),
imageLayers: $imageLayers,
);
}
private function checkCompatibility(array $selected, Collection $rules): array
{
$errors = [];
$selectedIds = array_column($selected, 'option_id');
foreach ($rules as $rule) {
$hasA = in_array($rule->option_a_id, $selectedIds);
$hasB = in_array($rule->option_b_id, $selectedIds);
if ($rule->type === 'forbidden' && $hasA && $hasB) {
$errors[] = $rule->message ?? 'Incompatible components';
}
if ($rule->type === 'required' && $hasA && !$hasB) {
$option = ConfigOption::find($rule->option_b_id);
$errors[] = $rule->message ?? "This option requires: {$option->name}";
}
}
return $errors;
}
}
API Endpoints
Route::get('/configurators/{id}', [ConfiguratorController::class, 'show']);
Route::post('/configurators/{id}/calculate', [ConfiguratorController::class, 'calculate']);
Route::post('/configurators/{id}/add-to-cart', [ConfiguratorController::class, 'addToCart']);
class ConfiguratorController extends Controller
{
public function calculate(Request $request, int $id): JsonResponse
{
$data = $request->validate([
'options' => 'required|array',
'options.*.group_id' => 'required|integer',
'options.*.option_id' => 'required|integer',
]);
$result = $this->engine->calculate($id, $data['options']);
return response()->json([
'valid' => $result->isValid,
'errors' => $result->errors,
'total_price' => $result->totalPrice,
'total_weight' => $result->totalWeight,
'config_sku' => $result->configSku,
'image_layers' => $result->imageLayers,
]);
}
}
Frontend Component
interface ConfigGroup {
id: number;
name: string;
type: 'radio' | 'checkbox';
options: ConfigOption[];
depends_on_group_id?: number;
depends_on_option_id?: number;
}
const Configurator: React.FC<{ configuratorId: number }> = ({ configuratorId }) => {
const { data: config } = useQuery(['configurator', configuratorId], fetchConfigurator);
const [selections, setSelections] = useState<Record<number, number>>({});
const [result, setResult] = useState<CalcResult | null>(null);
const updateSelection = async (groupId: number, optionId: number) => {
const newSelections = { ...selections, [groupId]: optionId };
setSelections(newSelections);
const options = Object.entries(newSelections).map(([gId, oId]) => ({
group_id: Number(gId), option_id: oId,
}));
const res = await api.post(`/configurators/${configuratorId}/calculate`, { options });
setResult(res.data);
};
const visibleGroups = config?.groups.filter(g => {
if (!g.depends_on_group_id) return true;
return selections[g.depends_on_group_id] === g.depends_on_option_id;
});
return (
<div className="space-y-6">
{visibleGroups?.map(group => (
<ConfigGroupWidget
key={group.id}
group={group}
selected={selections[group.id]}
onSelect={(optId) => updateSelection(group.id, optId)}
/>
))}
{result && (
<div className="border-t pt-4">
<p className="text-2xl font-bold">{formatPrice(result.total_price)}</p>
{result.errors.map((e, i) => (
<p key={i} className="text-red-500 text-sm">{e}</p>
))}
<button
disabled={!result.valid}
onClick={() => addToCart(configuratorId, selections)}
className="btn-primary mt-3 disabled:opacity-50"
>
Add to Cart
</button>
</div>
)}
</div>
);
};
Visual Configurator (Image Layers)
const ProductVisualizer: React.FC<{ baseSrc: string; layers: string[] }> = ({ baseSrc, layers }) => (
<div className="relative w-full aspect-square">
<img src={baseSrc} className="absolute inset-0 w-full h-full object-contain" alt="base" />
{layers.map((src, i) => (
<img
key={i}
src={src}
className="absolute inset-0 w-full h-full object-contain"
alt={`layer-${i}`}
/>
))}
</div>
);
Saving Configuration to Cart
CartItem::create([
'cart_id' => $cart->id,
'product_id' => $configurator->product_id,
'configurator_id' => $configurator->id,
'config_options' => json_encode($selectedOptions),
'config_sku' => $result->configSku,
'unit_price' => $result->totalPrice,
'quantity' => 1,
]);
Timeline
- Data schema + ConfiguratorEngine (no dependencies): 2 days
- Dependent groups + compatibility rules: +1 day
- API endpoints: 0.5 days
- Frontend radio/checkbox configurator: 2 days
- Visual configurator (layers): +1–2 days
- Admin interface for creating configurators: 2 days
Total without visualization: 6–7 days. With visualization: 8–9 days.







