As far as we understand the required product options. Then you need to create a plugin based on this interface https://git.drupalcode.org/project/basket/-/blob/9.x/src/Plugins/Params/BasketParamsInterface.php
And also display an additional field with options on the product page. Based on the interface, you should have the following plugin (example below)
<?php
namespace Drupal\MODULE_NAME\Plugin\Basket\Params;
use Drupal\basket\Plugins\Params\BasketParamsBaseForm;
/**
* @BasketParams(
* id = "goods_params",
* name = "Goods params",
* node_type = {"product"},
* )
*/
class GoodsParams extends BasketParamsBaseForm {
/**
* Form with parameters.
*/
public function getParamsForm(&$form, $form_state, $entity, $ajax){
$options = [];
foreach ($entity->FIELDS_VARIANS as $field) {
$options[$field->value] = $field->value;
}
if(!empty($options)){
$form['variant'] = [
'#type' => 'select',
'#options' => $options,
'#title' => 'Product variant',
'#default_value' => $form_state->getValue(['params', 'variant']),
];
if (empty($form_state->getValue(['params', 'variant']))) {
$form['variant']['#default_value'] = key($options);
}
$form_state->setValue(['params', 'variant'], $form['variant']['#default_value']);
}
}
/**
* Interpretation of parameters.
*/
public function getDefinitionParams(&$element, $params, $isInline = FALSE){
$node = $params['_entity'];
if (!empty($params['variant'])) {
$element[] = [
'#type' => 'item',
'#title' => 'Product variant: ',
'#markup' => $params['variant'],
];
}
}
/**
* Validation of parameters when adding / updating an order item.
*/
public function validParams(&$response, &$isValid, $post){
}
}
After you create the plugin, you will need to activate it in the basket /admin/basket/settings-node_types
And also display an additional field with parameters on the product page.