Can not access to the nth product's variation ( n > 1) programmatically
Basically, I wanted to get attributes attached to the current variation. According to Bojanz' answer: https://www.drupal.org/node/2893842#comment-12163314, there was no need to use $gift-&gt;variations. Bojanz corrected and told me $item-&gt;getPurchasedEntity() is the product variation, not the product

So the code would be: 

  /**
   * {@inheritdoc}
   */
  public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &amp;$complete_form) {
    $pane_form['#order_entity'] = $this-&gt;order;

    $order_items = $this-&gt;order-&gt;getItems();
    /** @var \Drupal\commerce_order\Entity\OrderItem $item */
    $item = $order_items[count($order_items) - 1]; // the last item added to the order
    /** @var \Drupal\commerce_product\Entity\ProductVariation $gift */
    $gift = $item-&gt;getPurchasedEntity();
    $attribute = $gift-&gt;getAttributeValue('attribute_gift_type');
  }