Configuration Endpoints
configurations/render is the aggregate endpoint used by this quickstart. It returns props, the normalized configuration, C-Tree, construction data, combination flow, SVG/views, pricing, description and rules. The same configuration payload can be sent to configurations/ctree, configurations/svg, configurations/pricing, configurations/description or configurations/rules when only one response slice is required. In the current backend implementation, these endpoints use the same configuration pipeline and then return only the requested slice.
';
$request=(array)($configuration['_request']??[]);
echo'Latest API Request
The exact JSON payload sent with the most recent configurator request. It shows the configuration state and all properties submitted to the API before the response is processed.
'.$h(strtoupper((string)($request['method']??'POST')).' /api.php/'.ltrim((string)($request['endpoint']??'configurations/render'),'/')).'
'.$h(json_encode($request['body']??[],JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES)).'
';
echo'Configuration Data Response
The normalized configuration state returned by the API. It contains the selected product, construction, dimensions, openings, component values and the configuration state of selected product combinations. Reuse this object as config in the next configurator request.
'.$h(json_encode($configuration['config']??[],JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES)).'
';
echo'
Configuration Tree Response
The complete configurable input structure for the current state. It describes available fields, options, constraints, attributes and display metadata and can be used to build a dynamic input form.
'.$h(json_encode($configuration['ctree']??[],JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES)).'
';
echo'
Pricing Response
The commercial calculation for the configuration, including price and delivery-time information on product and component level. product[0] contains the aggregated result for the complete configured product, including the total price and overall delivery time.
'.$h(json_encode($configuration['pricing']??[],JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES)).'
';
echo'
Description Response
The generated product description for the current configuration. The rows can be used directly for summaries or document positions and may already include calculated price information and nested description levels.
'.$h(json_encode($configuration['description']??[],JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES)).'
';
echo'
Rules Response
The current rule evaluation for the configuration. It contains informational and blocking messages, pending confirmations, applied rules and the final can_save state. Some rules only transform or validate the configuration in the background, while others require an explicit decision.
'.$h(json_encode($configuration['rules']??[],JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES)).'
';
echo'';
}
try{
$api=fenzonApi($apiKey,$apiBase);
$config=[];
$action=[];
$mode='parent';
$parentConfig=[];
$parentConfirmRules=[];
$parentSkipRules=[];
$parentUpdate='';
$combinationKey='';
$combinationMeta=[];
$type='';
if(($_SERVER['REQUEST_METHOD']??'GET')==='POST'){
$config=json_decode((string)($_POST['config']??''),true)?:[];
$parentConfig=json_decode((string)($_POST['parentConfig']??''),true)?:[];
$parentConfirmRules=json_decode((string)($_POST['parentConfirmRules']??''),true)?:[];
$parentSkipRules=json_decode((string)($_POST['parentSkipRules']??''),true)?:[];
$parentUpdate=(string)($_POST['parentUpdate']??'');
$combinationMeta=json_decode((string)($_POST['combinationMeta']??''),true)?:[];
$confirmRules=json_decode((string)($_POST['confirmRules']??''),true)?:[];
$skipRules=json_decode((string)($_POST['skipRules']??''),true)?:[];
$type=(string)($_POST['action']??'');
$mode=(string)($_POST['mode']??'parent');
$combinationKey=(string)($_POST['combinationKey']??'');
$action=['confirmRules'=>$confirmRules,'skipRules'=>$skipRules,'update'=>(string)($_POST['update']??'')];
if($type==='change'){$action['field']=(string)($_POST['field']??'');$action['value']=$_POST['value']??'';}
elseif($type==='confirm')$action['confirm']=(int)($_POST['rule']??0);
elseif($type==='skip')$action['skip']=(int)($_POST['rule']??0);
elseif(in_array($type,['validate','saveExisting','saveNew','applyCombination'],true))$action['validate']=true;
}
if($type==='openCombination'){
$parentConfiguration=fenzonConfigurator($api,$productId,$config,$action,$configProps);
$combinationKey=(string)($_POST['combinationKey']??'');
$child=null;
foreach((array)($parentConfiguration['combinationFlow']['configurable']??[])as$item)if((string)($item['key']??'')===$combinationKey){$child=$item;break;}
if(!is_array($child))throw new RuntimeException('The selected combination configuration is not available.');
$childConfig=(array)($child['config']??[]);
$childProduct=$childConfig['product'][0]??($child['product']??0);
if(is_array($childProduct))$childProduct=$childProduct['id']??reset($childProduct);
if(is_string($childProduct)&&str_starts_with($childProduct,'connect:'))$childProduct=(int)substr(strrchr($childProduct,':')?:':0',1);
$childProps=array_replace($configProps,['combinationChild'=>true,'ctreeContext'=>['combination'=>(array)($child['compatibility']??[])]]);
$configuration=fenzonConfigurator($api,max(1,(int)$childProduct),$childConfig,[],$childProps);
$configuration['_quickstart']=['mode'=>'combination','parentConfig'=>$parentConfiguration['config']??$config,'parentConfirmRules'=>$parentConfiguration['props']['confirmRules']??[],'parentSkipRules'=>$parentConfiguration['props']['skipRules']??[],'parentUpdate'=>$parentConfiguration['props']['update']??'','combinationKey'=>$combinationKey,'combinationMeta'=>['key'=>$combinationKey,'name'=>$child['name']??'','class'=>$child['class']??'','relation_id'=>$child['relation_id']??0,'scope'=>$child['scope']??'element','section'=>$child['section']??null,'compatibility'=>$child['compatibility']??[]]];
}elseif($mode==='combination'&&$combinationKey!==''){
$parentAction=['confirmRules'=>$parentConfirmRules,'skipRules'=>$parentSkipRules,'update'=>$parentUpdate];
if($type==='backCombination'){
$configuration=fenzonConfigurator($api,$productId,$parentConfig,$parentAction,$configProps);
}elseif($type==='removeCombination'){
$scope=(string)($combinationMeta['scope']??'element');$section=(string)($combinationMeta['section']??'0');$class=(string)($combinationMeta['class']??'');
if($scope==='section')unset($parentConfig['combination']['section'][$section][$class]);else unset($parentConfig['combination']['element'][$class]);
$configuration=fenzonConfigurator($api,$productId,$parentConfig,$parentAction,$configProps);
}elseif($type==='applyCombination'){
$childProps=array_replace($configProps,['combinationChild'=>true,'ctreeContext'=>['combination'=>(array)($combinationMeta['compatibility']??[])]]);
$childProduct=$config['product'][0]??0;if(is_array($childProduct))$childProduct=$childProduct['id']??reset($childProduct);if(is_string($childProduct)&&str_starts_with($childProduct,'connect:'))$childProduct=(int)substr(strrchr($childProduct,':')?:':0',1);
$childConfiguration=fenzonConfigurator($api,max(1,(int)$childProduct),$config,$action,$childProps);
if(empty($childConfiguration['rules']['can_save']))throw new RuntimeException('Resolve the combination rules before applying the child configuration.');
$scope=(string)($combinationMeta['scope']??'element');$section=(string)($combinationMeta['section']??'0');$class=(string)($combinationMeta['class']??'');$relation=(int)($combinationMeta['relation_id']??0);
$entry=['relation'=>$relation,'config'=>(array)($childConfiguration['config']??$config)];
if($scope==='section')$parentConfig['combination']['section'][$section][$class]=$entry;else$parentConfig['combination']['element'][$class]=$entry;
$configuration=fenzonConfigurator($api,$productId,$parentConfig,$parentAction,$configProps);
}else{
$childProps=array_replace($configProps,['combinationChild'=>true,'ctreeContext'=>['combination'=>(array)($combinationMeta['compatibility']??[])]]);
$childProduct=$config['product'][0]??0;if(is_array($childProduct))$childProduct=$childProduct['id']??reset($childProduct);if(is_string($childProduct)&&str_starts_with($childProduct,'connect:'))$childProduct=(int)substr(strrchr($childProduct,':')?:':0',1);
$configuration=fenzonConfigurator($api,max(1,(int)$childProduct),$config,$action,$childProps);
$configuration['_quickstart']=['mode'=>'combination','parentConfig'=>$parentConfig,'parentConfirmRules'=>$parentConfirmRules,'parentSkipRules'=>$parentSkipRules,'parentUpdate'=>$parentUpdate,'combinationKey'=>$combinationKey,'combinationMeta'=>$combinationMeta];
}
}else{
$configuration=fenzonConfigurator($api,$productId,$config,$action,$configProps);
}
if(($_SERVER['REQUEST_METHOD']??'GET')==='POST'&&in_array($type,['saveExisting','saveNew'],true)){
$saved=saveConfiguration(
$api,
$configuration,
$type==='saveExisting'?(int)($_POST['documentId']??0):0,
$type==='saveNew'?(int)($_POST['accountId']??0):0
);
$configuration['_notice']=$saved['document_created']
?'A new quote was created and the configuration was added as a document item.'
:'The configuration was added to the existing document.';
}
renderConfigurator($configuration,$configView);
}catch(Throwable$e){
http_response_code(500);
header('Content-Type: text/plain; charset=utf-8');
echo "Fenzon Configurator Quickstart\n\n".$e->getMessage()."\n";
}