I want to at a — select a product from list — option in product list page using commerce module. using product list view.Added the code as below but it through an error
file location: /code/modules/contrib/commerce/modules/product/src/Plugin/Field/FieldWidget/ProductVariationTitleWidget.php
$element['variation'] = [ '#type' => 'select', // Widget settings can't be translated in D8 yet, t() is a workaround. '#title' => $this->t($this->getSetting('label_text')), '#options' => array_merge(array("--- Please select a product ---"), $variation_options), '#required' => TRUE, '#default_value' => !empty($selected_variation) ? $selected_variation->id() : '', '#ajax' => [ 'callback' => [get_class($this), 'ajaxRefresh'], 'wrapper' => $form['#wrapper_id'], ], ];