You are here

function commerce_checkout_entity_base_field_info in Commerce Core 8.2

Implements hook_entity_base_field_info().

File

modules/checkout/commerce_checkout.module, line 99
Provides configurable checkout flows.

Code

function commerce_checkout_entity_base_field_info(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->id() === 'commerce_order') {
    $fields['checkout_flow'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Checkout flow'))
      ->setSetting('target_type', 'commerce_checkout_flow')
      ->setSetting('handler', 'default')
      ->setDisplayOptions('form', [
      'region' => 'hidden',
    ])
      ->setDisplayConfigurable('view', FALSE)
      ->setDisplayConfigurable('form', FALSE);

    // @todo Implement a custom widget that shows itself when the flow is set
    // and allows a step to be chosen from a dropdown.
    $fields['checkout_step'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Checkout step'))
      ->setDisplayOptions('form', [
      'region' => 'hidden',
    ])
      ->setDisplayConfigurable('view', FALSE)
      ->setDisplayConfigurable('form', FALSE);
    return $fields;
  }
}