Transaction, add relationships to order/order_item

Created on 12 April 2025, 7 days ago

Since issue 📌 Giftcard transaction reference Needs work a transaction tracks references to:

  1. The commerce order item and hence the order for positive transactions (customer bought a gift card)
  2. The commerce order for negative transactions (customer used a gift card)

To use those information's for e.g. creating an integrated view and show the connections to these orders, we need to add relationships.

Probably it would make sense, to do this within the module, and not in "custom code".
The relationships would be defined similarly as follows:

  $data['commerce_giftcard_transaction']['reference_id']['relationship'] = [
    'base' => 'commerce_order_item',
    'base field' => 'order_item_id',
    'id' => 'standard',
    'label' => t('Commerce order item'),
    'title' => t('Commerce order item'),
  ];

  $data['commerce_giftcard_transaction']['reference_id_order'] = [
    'title' => t('Reference to order'),
    'help' => t('Reference to order (giftcard use)'),
    'relationship' => [
      'base' => 'commerce_order',
      'base field' => 'order_id',
      'id' => 'standard',
      'label' => t('Commerce order'),
      'title' => t('Commerce order'),
    ],
    'real field' => 'reference_id'
  ];

Maybe it would also be easier, if we track those references in separate fields. (single point of responsibility principle)

What do you think?

Feature request
Status

Active

Version

2.0

Component

Code

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024