diff --git a/web/modules/custom/materio_commerce/materio_commerce.module b/web/modules/custom/materio_commerce/materio_commerce.module
index 908092b0..b3bca4fc 100644
--- a/web/modules/custom/materio_commerce/materio_commerce.module
+++ b/web/modules/custom/materio_commerce/materio_commerce.module
@@ -97,6 +97,7 @@ function materio_commerce_form_role_delegation_role_assign_form_alter(&$form, &$
'@num' => $order_number,
'@state' => $order_state
)), $order_url);
+
}
$description .= t("-- @product: @variation | license state: @license_state | granted: @granted | expires: @expires | @license_link | @order_link
", array(
@@ -202,23 +203,51 @@ function materio_commerce_form_user_form_alter(&$form, &$form_state, $form_id) {
$order = $license->getOriginatingOrder();
if ($order) {
+ // payments
+ $payment_storage = \Drupal::entityTypeManager()->getStorage('commerce_payment');
+ $payments = $payment_storage->loadByProperties(['order_id' => $order->id()]);
+ if (!empty($payments)) {
+ $first_payment = array_shift($payments);
+ $gateway = $first_payment->get('payment_gateway')->first()->getValue()['target_id'];
+ }
+
+ // order info and link
$order_url = $order->toUrl();
$order_state = $order->get('state')->first()->getValue()['value'];
- $order_number = $order->get('order_number')->first()->getValue()['value'];
- $order_link = Link::fromTextAndUrl(t("order @num (@state)", array(
- '@num' => $order_number,
- '@state' => $order_state
+ // $order_number = $order->get('order_number')->first()->getValue()['value'];
+ $order_link = Link::fromTextAndUrl(t("order (@gateway @state)", array(
+ // '@num' => $order_number,
+ '@state' => $order_state,
+ '@gateway' => isset($gateway) ? $gateway : ''
)), $order_url);
+
+ // susbcriptions
+ $susbcription_storage = \Drupal::entityTypeManager()->getStorage('commerce_subscription');
+ $subsriptions = $susbcription_storage->loadByProperties(['initial_order' => $order->id()]);
+ if (!empty($subsriptions)) {
+ $first_subscription = array_shift($subsriptions);
+ $subscription_url = $first_subscription->toUrl();
+ $subscription_title = $first_subscription->getTitle();
+ $subscription_state = $first_subscription->get('state')->first()->getValue()['value'];
+ $subscription_payment_method = $first_subscription->getPaymentMethod();
+ $subscription_payment_method_label = $subscription_payment_method->label()->render();
+ $subscription_link = Link::fromTextAndUrl(t("subscription @title @state [@pm_label]", array(
+ '@title' => $subscription_title,
+ '@state' => $subscription_state,
+ '@pm_label' => $subscription_payment_method_label
+ )), $subscription_url);
+ }
}
- $description .= t("-- @product: @variation | license state: @license_state | granted: @granted | expires: @expires | @license_link | @order_link
", array(
+ $description .= t("-- @product: @variation | license state: @license_state | granted: @granted | expires: @expires | @license_link | @subscription_link | @order_link
", array(
'@product' => $product ? $product->getTitle() : t('no product'),
'@variation' => $product_variation ? $product_variation->getTitle() : t('no variation'),
'@license_state' => $license_state,
'@granted' => date('d-m-Y', $granted),
'@expires' => $expires === "0" ? 'never' : date('d-m-Y', $expires),
'@license_link' => $license_link->toString(),
- '@order_link' => $order ? $order_link->toString() : t('no order')
+ '@subscription_link' => isset($subscription_link) ? $subscription_link->toString() : t('no subscription'),
+ '@order_link' => isset($order) ? $order_link->toString() : t('no order')
));
}