How to display a field of the parent store in my module? I have a Drupal 8.7 site with the Drupal Commerce 2.14 module.

I created a marketplace (several merchants on the same site). In the store type, I created a "Text (formatted, long)" field with the machine name field_terms_and_conditions.

In this field, the merchant writes his general conditions of sale, which the customer will have to accept during the order process.

When the customer orders in several stores, this will create several shopping carts (the name of the store is displayed above each shopping cart). It works very well. Now that Drupal Commerce is handling the address book, the orders are very fast.

Currently I have created a view that displays the contents of the field field_terms_and_conditions on a page. I also created a custom module to display a checkbox with a link to the general conditions of sale in a modal window.

I want to directly render the field field_terms_and_conditions in the modal window without using a view. How to do this ?

/src/Plugin/Commerce/CheckoutPane/MarketplaceTermsAndConditions.php :

&lt;?php

namespace Drupal\commerce_marketplace_terms_and_conditions\Plugin\Commerce\CheckoutPane;

use Drupal\Component\Serialization\Json;
use Drupal\Core\Form\FormStateInterface;
use Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneBase;
use Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;

/**
 * Provides the completion message pane.
 *
 * @CommerceCheckoutPane(
 *   id = "marketplace_terms_and_conditions",
 *   label = @Translation("Marketplace Terms and Conditions"),
 *   default_step = "review",
 * )
 */
class MarketplaceTermsAndConditions extends CheckoutPaneBase implements CheckoutPaneInterface {

  /**
   * {@inheritdoc}
   */
  public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &amp;$complete_form) {
    $store_name = $this-&gt;order-&gt;getStore()-&gt;getName();
    $store_id = $this-&gt;order-&gt;getStoreId();
    $pane_form['#attached']['library'][] = 'core/drupal.dialog.ajax';
    $attributes = [
      'attributes' =&gt; [
        'class' =&gt; 'use-ajax',
        'data-dialog-type' =&gt; 'modal',
        'data-dialog-options' =&gt; Json::encode([
          'width' =&gt; 'auto'
        ]),
      ],
    ];
    $link = Link::fromTextAndUrl(
      $this-&gt;t('terms and conditions of the store "@store_name"', ['@store_name' =&gt; $store_name]),
      Url::fromUri("internal:/store/$store_id/cgv", $attributes)
    )-&gt;toString();
    $pane_form['marketplace_terms_and_conditions'] = [
      '#type' =&gt; 'checkbox',
      '#default_value' =&gt; FALSE,
      '#title' =&gt; $this-&gt;t('I have read and accept @terms.', ['@terms' =&gt; $link]),
      '#required' =&gt; TRUE,
      '#weight' =&gt; $this-&gt;getWeight(),
    ];
    return $pane_form;
  }

}
Sounds fun, Here is an option to do this. 

1) make a controller :
routingfile:

my_module.store_terms:
  path: '/store-terms/{store_id}'
  defaults:
    _controller: '\Drupal\my_module\Controller\StoreTermsController::showTerms'
    _title: 'Terms'
  requirements:
    _permission: 'access content'


In the controller:

use Drupal\Core\Ajax\AjaxResponse;

use Drupal\Core\Ajax\OpenModalDialogCommand;

public function showTerms($store_id) {
  $store = \Drupal::entityTypeManager()-&gt;getStorage('commerce_store')-&gt;load($store_id);

  $terms = $store-&gt;field_terms_and_condition-&gt;value;

  $render_array = [
    '#markup' =&gt; $terms
  ];
  $response = new AjaxResponse();
  // Show a dialog box.
  $dialogText = $render_array;
  $dialogText['#attached']['library'][] = 'core/drupal.dialog.ajax';
  $response-&gt;addCommand(new OpenModalDialogCommand('Terms and Conditions', 
   $dialogText, ['width' =&gt; '500']));
  return $response;
}


then back in your  buildPaneForm method:

$attributes = [
  'attributes' =&gt; [
    'class' =&gt; 'use-ajax',
    ],
];
$link = Link::fromTextAndUrl(
  t('terms and conditions of the store "@store_name"', ['@store_name' =&gt; 
   $store_name]),
  Url::fromUri("internal:/store-terms/".$store_id , $attributes)
  )-&gt;toString();