Commit c4bea2d7 authored by Matt Glaman's avatar Matt Glaman
Browse files

Issue #2660300: Do not display variation dropdown if only one variation

parent fa76aba2
Loading
Loading
Loading
Loading
+12 −0
Changes for modules/product/src/Form/AddToCartForm.php: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -97,11 +97,23 @@ class AddToCartForm extends FormBase {
    }

    $form['#settings'] = $settings;

    // If there are multiple variations, display ability to select a variation.
    if (count($variations) > 1) {
      $form['variation'] = [
        '#type' => 'select',
        '#title' => $this->t('Select variation:'),
        '#options' => $variations,
      ];
    }
    // Otherwise set the variation and only display "add to cart".
    else {
      $form['variation'] = [
        '#type' => 'value',
        '#value' => key($variations),
      ];
    }

    if (!empty($settings['show_quantity'])) {
      $form['quantity'] = [
        '#type' => 'number',
+1 −1

File changed.

Contains only whitespace changes.