reversed license order newer first, license form selection list for product variation

This commit is contained in:
Bachir Soussi Chiadmi 2022-11-17 22:50:20 +01:00
parent ad3ef95a7b
commit dd38d8d2b2
2 changed files with 8 additions and 10 deletions

View File

@ -11,14 +11,10 @@ bundle: role
mode: default mode: default
content: content:
product_variation: product_variation:
type: entity_reference_autocomplete type: options_select
weight: 0 weight: 0
region: content region: content
settings: settings: { }
match_operator: CONTAINS
match_limit: 10
size: 60
placeholder: ''
third_party_settings: { } third_party_settings: { }
state: state:
type: options_select type: options_select

View File

@ -68,7 +68,8 @@ function materio_commerce_form_role_delegation_role_assign_form_alter(&$form, &$
$description = t("This role is granted by a license. It cannot be removed manually.<br/>"); $description = t("This role is granted by a license. It cannot be removed manually.<br/>");
} }
foreach ($role_licenses['licenses'] as $license) { $reversed_licenses = array_reverse($role_licenses['licenses']);
foreach ($reversed_licenses as $license) {
$license_state = $license->getState()->getValue()['value']; $license_state = $license->getState()->getValue()['value'];
$product_variation = $license->getPurchasedEntity(); $product_variation = $license->getPurchasedEntity();
@ -94,7 +95,7 @@ function materio_commerce_form_role_delegation_role_assign_form_alter(&$form, &$
)), $order_url); )), $order_url);
} }
$description .= t("-- @product: @variation | license state: @license_state | granted: @granted | expires: @expires | @license_link | @order_link<br/>", array( $description .= t("-- @product: @variation | license state: <b>@license_state</b> | granted: @granted | expires: @expires | @license_link | @order_link<br/>", array(
'@product' => $product ? $product->getTitle() : t('no product'), '@product' => $product ? $product->getTitle() : t('no product'),
'@variation' => $product_variation ? $product_variation->getTitle() : t('no variation'), '@variation' => $product_variation ? $product_variation->getTitle() : t('no variation'),
'@license_state' => $license_state, '@license_state' => $license_state,
@ -158,7 +159,8 @@ function materio_commerce_form_user_form_alter(&$form, &$form_state, $form_id) {
$description = t("This role is granted by a license. It cannot be removed manually.<br/>"); $description = t("This role is granted by a license. It cannot be removed manually.<br/>");
} }
foreach ($role_licenses['licenses'] as $license) { $reversed_licenses = array_reverse($role_licenses['licenses']);
foreach ($reversed_licenses as $license) {
$license_state = $license->getState()->getValue()['value']; $license_state = $license->getState()->getValue()['value'];
$product_variation = $license->getPurchasedEntity(); $product_variation = $license->getPurchasedEntity();
@ -184,7 +186,7 @@ function materio_commerce_form_user_form_alter(&$form, &$form_state, $form_id) {
)), $order_url); )), $order_url);
} }
$description .= t("-- @product: @variation | license state: @license_state | granted: @granted | expires: @expires | @license_link | @order_link<br/>", array( $description .= t("-- @product: @variation | license state: <b>@license_state</b> | granted: @granted | expires: @expires | @license_link | @order_link<br/>", array(
'@product' => $product ? $product->getTitle() : t('no product'), '@product' => $product ? $product->getTitle() : t('no product'),
'@variation' => $product_variation ? $product_variation->getTitle() : t('no variation'), '@variation' => $product_variation ? $product_variation->getTitle() : t('no variation'),
'@license_state' => $license_state, '@license_state' => $license_state,