commerce_promotion_test.module in Commerce Core 8.2
Test module for Promotion.
File
modules/promotion/tests/modules/commerce_promotion_test/commerce_promotion_test.moduleView source
<?php
/**
* @file
* Test module for Promotion.
*/
use Drupal\Component\Utility\Html;
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
function commerce_promotion_test_form_views_form_commerce_cart_form_default_alter(&$form, FormStateInterface $form_state, $form_id) {
// We know that view forms are build on the base ID plus arguments.
$order_id = substr($form_id, strlen('views_form_commerce_cart_form_default_'));
$inline_form_manager = \Drupal::getContainer()
->get('plugin.manager.commerce_inline_form');
$inline_form = $inline_form_manager
->createInstance('coupon_redemption', [
'order_id' => $order_id,
'max_coupons' => Drupal::request()->query
->get('coupon_cardinality'),
]);
// Workaround for core bug #2897377.
$form['#id'] = Html::getId($form_state
->getBuildInfo()['form_id']);
$form['coupons'] = [
'#parents' => [
'coupons',
],
];
$form['coupons'] = $inline_form
->buildInlineForm($form['coupons'], $form_state);
}
Functions
Name![]() |
Description |
---|---|
commerce_promotion_test_form_views_form_commerce_cart_form_default_alter | Implements hook_form_BASE_FORM_ID_alter(). |