Use order number instead of order ID in generated document filenames

Created on 24 February 2025, about 2 months ago

Problem/Motivation

When generating filenames for order documents, the internal order ID is used instead of the customer-facing order number. This makes it harder for users to identify downloaded files since they typically reference orders by their order number rather than internal IDs.

Steps to reproduce

  1. Create an order in Commerce which has an order number different from its ID
  2. Create an order document for this order
  3. Download the document
  4. Observe that the filename contains the order ID (e.g. "Order 123 Invoice") rather than the order number (e.g. "Order ORD-2024-001 Invoice")

Proposed resolution

Modify the getFilename() method in OrderDocumentRenderer.php to use getOrderNumber() instead of id() when generating filenames for order documents.

Remaining tasks

  1. Update the code in OrderDocumentRenderer.php
  2. Add test coverage for filename generation
  3. Update documentation if needed

User interface changes

The only change will be in the generated filenames for downloaded order documents, which will now show the order number instead of the internal ID.

API changes

None. This is an internal change to how filenames are generated.

Data model changes

None. This only affects the display/output of existing data.

๐Ÿ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States Dave Kopecek

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

Merge Requests

Comments & Activities

  • Issue created by @Dave Kopecek
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States lisastreeter

    Excellent idea. I can't think of any reason not to make the change.

    My only issue is that I'm a bit of a novice when it comes to Drupal module maintainership.
    I've just created a new dev branch. Would you be able to rework your merge request so that it's for that branch (so that I'm not messing with the release branch)? And then after I merge your work into the dev branch I can open a new release version and merge dev into that.

    Sorry I didn't have all this setup properly before you did this work.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States lisastreeter

    Actually, @dave-kopecek, disregard my previous message. I've been reading more about how to manage merge requests and releases. I think I can just merge into 1.0.x and then tag a new release for the update.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States Dave Kopecek

    I'm not an expert on this, but our AI overlords at ChatGPT think that with your maintainer access you may be able to merge my merge request into the 1.0.x-dev branch. The manual method in step 3 looks pretty straightforward. Here's what was suggested by ChatGPT:

    It is possible to merge an issue fork's merge request into the 1.0.x-dev branch. In Drupal's GitLab-based workflow:

    1. Ensure the Merge Request Targets the Correct Branch

    • - If the issue fork was created against 1.0.x, check that the merge request targets 1.0.x-dev (this is typically the active development branch for that minor version).
    • - If the MR targets 1.0.x instead of 1.0.x-dev, you may need to update the target branch before merging.

    2. Rebase if Necessary

    • If 1.0.x-dev has new changes that are not in the issue fork, you may need to rebase the fork before merging to avoid conflicts.

    3. Merge via GitLab Interface

    • - If everything looks good, merge the MR into 1.0.x-dev using GitLabโ€™s merge request UI.
    • - Alternatively, merge manually via the command line:
    git fetch origin
    git checkout 1.0.x-dev
    git merge --no-ff issue-branch
    git push origin 1.0.x-dev

    4. Confirm Branch Policies

    - In some projects, 1.0.x is reserved for tagged releases, while 1.0.x-dev is the development branch. Always check project policies before merging.

    --- end of chatgpt ---

    I've only ever created Drupal issue forks by clicking the "Create issue fork" on the issue. I think the only way for me to create a new fork is to open a new issue. Happy to do whatever is needed. Let me know how you want to proceed.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States Dave Kopecek

    @lisastreeter looks like we were googling about merge requests at the same time :-)

Production build 0.71.5 2024