diff --git a/src/fields/formfields/Variants.php b/src/fields/formfields/Variants.php index bc73cf911..8824a7e21 100644 --- a/src/fields/formfields/Variants.php +++ b/src/fields/formfields/Variants.php @@ -78,6 +78,7 @@ public static function getSvgIconPath(): string // ========================================================================= public bool $searchable = true; + public bool $allowMultipleSources = false; protected string $inputTemplate = 'formie/_includes/element-select-input'; @@ -112,8 +113,15 @@ public function getExtraBaseFieldConfig(): array */ public function getFieldDefaults(): array { + $productType = null; + $productTypes = Commerce::getInstance()->getProductTypes()->getAllProductTypes(); + + if (!empty($productTypes)) { + $productType = 'productType:' . ArrayHelper::firstValue($productTypes)->uid; + } + return [ - 'source' => '*', + 'source' => $productType, 'placeholder' => Craft::t('formie', 'Select a variant'), 'labelSource' => 'title', 'orderBy' => 'title ASC',