Purpose of order receipt theme suggestions/overrides

Created on 12 March 2024, 9 months ago
Updated 26 August 2024, 4 months ago

Problem/Motivation

Just want to report that having the `hook_theme_suggestions_HOOK_alter` and receipt template in this module provided a poor DX for me. It took me a minute to realize this module was overriding the commerce (and my theme) templates because of the suggestion. Also, the template appears to be the exact same, so I'm not sure why this exists.

Proposed resolution

Remove the `hook_theme_suggestions_HOOK_alter` and template, let theme decide when and how to override the template.

You can close as designed or provide a reason for this since I'm not seeing. Just reporting that it caused me some extra time.

Thanks,
Andy

πŸ’¬ Support request
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States andyg5000 North Carolina, USA

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

Merge Requests

Comments & Activities

  • Issue created by @andyg5000
  • πŸ‡ΊπŸ‡ΈUnited States fathershawn New York

    Hi - thanks for the feedback. I wrote that method 7 years ago, when this was a customization for client and not yet contributed, so my best guess is I needed it for that work.

    Perhaps the best DX solution at this point is to remove the template but leave the suggestion, since Commerce adds the order bundle type but not the gateway ID as a suggestion

  • Status changed to Needs review 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States fathershawn New York

    A closer look and I have a better answer. There is a small but important difference between the templates.

    The template at commerce/modules/order/templates/commerce-order-receipt.html.twig has this block:

    {% block payment_method %}
      {{ payment_method }}
    {% endblock %}
    

    And the template in this module has:

    {% block payment_method %}
      {{ payment_method }}
      {{ payment_instructions }}
    {% endblock %}
    

    The payment instruction info is preprocessed in commerce_purchase_order_preprocess_commerce_order_receipt. I've changed the template in this module to a clear twig block override. Please would this have saved you time?

  • πŸ‡ΊπŸ‡ΈUnited States andyg5000 North Carolina, USA

    Hey Shawn,

    Thanks for making the update and explaining the preprocess. I think all of this makes sense.

    Thanks,
    Andy

Production build 0.71.5 2024