Correlate stock transactions to order items

Created on 23 September 2025, about 2 months ago

Problem/Motivation

Currently, stock transactions can be correlated to other transactions (i.e., supporting a sell transaction to its original receipt transaction) and to orders, but it's possible that a single order might generate multiple stock transactions even for the same product variation.

For example, if you are actually trying to correlate all sell transactions to previous receipt transactions, you might need multiple sell transactions to reference different original receipt transactions / unit costs. Right now you'd simply have to load any transaction related to the order and then group them by purchased entity ID.

Proposed resolution

Similar to the related_tid and related_oid columns in the commerce_stock_transaction table, add a related_oiid column to allow individual transactions to be correlated to order items.

Generally speaking, this would also deprecate the need for a related_oid field, but it's possible a site may choose one strategy over another or benefit from the more direct query here. No need to remove the order ID correlation unless it was just desirable for other reasons as of the next major version.

✨ Feature request
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States rszrama

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024