Add customer-facing order comments

Created on 2 March 2022, almost 3 years ago
Updated 31 March 2023, over 1 year ago

Add "Customer-facing comment" that an admin can use in each order to communicate with customers by commerce log and to send an Email to customers if needed. Split from Add ability to add an order comment Fixed .

Feature request
Status

Needs review

Version

2.0

Component

Log

Created by

🇮🇳India vipin.j

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • Will this patch has a chance to get merged? Or should I continue looking for other method?

    Thanks,

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    781 pass
  • 🇮🇳India vipin.j

    The patch #18 is re-rolled with updates for release ^2.35 compatibility.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    786 pass
  • 🇮🇳India vipin.j

    Small tweak in the patch to remove one of the WCAG 2.1 issue.

  • Status changed to Needs work 12 months ago
  • 🇨🇭Switzerland Lukas von Blarer

    This needs a re-roll.

  • Status changed to Needs review 12 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 12 months ago
    788 pass, 2 fail
  • 🇨🇭Switzerland Lukas von Blarer

    Ok, here is a re-roll.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 12 months ago
    790 pass
  • 🇨🇭Switzerland Lukas von Blarer

    Sorry, I forgot to add the new files.

  • Status changed to RTBC 12 months ago
  • Tested #24 with latest dev and works.

    Thanks,

  • Status changed to Active 10 months ago
  • 🇬🇧United Kingdom nags338228

    Hi,

    I patched with https://www.drupal.org/project/commerce/issues/3267366 Add customer-facing order comments Active and https://www.drupal.org/project/commerce/issues/2908196 Add ability to add an order comment Fixed this issue and merged both of it.

    The #25 patch contains Comment form in user order page for the user along with permissions + comment form for admin with radio buttons and sending email functionality.

    Please test it

    Thanks !!

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 10 months ago
    Patch Failed to Apply
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 5.7
    last update 10 months ago
    Patch Failed to Apply
  • Status changed to Needs review 10 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 10 months ago
    784 pass, 2 fail
  • 🇮🇳India vipin.j

    From patch #6 we are carrying a deprecated statement which has fixed with the issue #3336658 📌 PHP 8.2: ${var} in strings is deprecated Fixed

    Re-rolling patch #24 to fix this issue in the patch.

  • 🇸🇰Slovakia poker10

    I think that a possibility to add customer-facing order comments is an important feature, so +1 from me and hopefully we will see this in Drupal Commerce soon. As it was mentioned in the referenced issue ( 💬 How to Add Order Comment and also Allow to notify customer via email? Active ), each other eshop system has such comments (magento, ubercart, prestashop, opencart).

  • 🇺🇦Ukraine khiminrm

    I've tested patch from #27.
    It works.
    But I've noticed one bug:
    When add comment and go to review page,
    on review page click on Edit near the Comments section
    then the page with previous checkout step is opened and the Comment input field is empty.
    Adding new comment in this case and submitting checkout step form again will save the comment as new log.
    So there are two comment logs.
    I haven't time to look into code and check if it's possible to load already created comment log yet.
    Maybe it should be fixed?

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 10 months ago
    791 pass
  • 🇺🇦Ukraine khiminrm

    I've fixed the bug from the previous comment.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 10 months ago
    791 pass
  • 🇺🇦Ukraine khiminrm

    Added one more small fix to render a customer comment on the order review page with new lines (if there any in the comment) and not '
    ' instead.

  • Status changed to Needs work 10 months ago
  • 🇸🇰Slovakia poker10

    Thanks for working on this. I have quickly checked the patch and writing a few points.

    1. I think there are some unrelated changes, or at least not explained:

    +++ b/modules/payment/tests/src/Functional/DefaultPaymentAdminTest.php
    @@ -132,7 +132,7 @@ class DefaultPaymentAdminTest extends CommerceBrowserTestBase {
           [
             'absolute' => TRUE,
           ],
    -    )->toString();
    +    )->getInternalPath();
       }
    
    +++ b/modules/order/tests/src/FunctionalJavascript/OrderAdminTest.php
    @@ -424,7 +424,7 @@ class OrderAdminTest extends OrderWebDriverTestBase { 
    -    $this->drupalGet($order->toUrl()->toString());
    +    $this->drupalGet($order->toUrl());
     
    @@ -462,14 +462,14 @@ class OrderAdminTest extends OrderWebDriverTestBase {
    -    $this->drupalGet($order->toUrl()->toString());
    +    $this->drupalGet($order->toUrl());
     
         // Logout and check that anonymous users cannot see the order admin screen.
         $this->drupalLogout();
    -    $this->drupalGet($order->toUrl()->toString());
    +    $this->drupalGet($order->toUrl());
       }
    
    +++ b/modules/order/src/Mail/OrderReceiptMail.php
    @@ -30,7 +31,7 @@ class OrderReceiptMail implements OrderReceiptMailInterface {
    -  public function send(OrderInterface $order, $to = NULL, $bcc = NULL, bool $resend = FALSE) {
    +  public function send(OrderInterface $order, $to = NULL, $bcc = NULL, bool $resend = FALSE): bool {
    
    +++ b/modules/order/commerce_order.module
    @@ -181,8 +182,8 @@ function template_preprocess_commerce_order(array &$variables) {
    -    $profile_view_bulder = \Drupal::entityTypeManager()->getViewBuilder('profile');
    -    $variables['order']['billing_information'] = $profile_view_bulder->view($billing_profile, $view_mode);
    +    $profile_view_builder = \Drupal::entityTypeManager()->getViewBuilder('profile');
    +    $variables['order']['billing_information'] = $profile_view_builder->view($billing_profile, $view_mode);
    

    2. Regarding the templates - I think it would be a little weird to display it this way. As far as I understand, we can have only one comment of type "From customer". Maybe it should be out of foreach to not cause a confusion. Then we should have a foreach just for "To customer" comments and there would be no need to write "Comment to customer" for each row. This is the related code:

    +++ b/modules/order/templates/commerce-order-receipt.html.twig
    @@ -133,6 +134,44 @@
    +                    {% for comment in order_comments %}
    +                      <tr>
    +                        {% if comment.type == 'commerce_order.comment.to_customer' %}
    +                          <td style="border: 1px solid #dee2e6; padding: 0.75rem; vertical-align: top;">{{ comment.date|date("D, m/d/Y - H:i") }}</td>
    +                          <td style="border: 1px solid #dee2e6; padding: 0.75rem; vertical-align: top;"><strong>Comment to customer:</strong> <br />{{ comment.comment|raw }}</td>
    +                        {% elseif comment.type == 'commerce_order.comment.from_customer' %}
    +                          <td style="border: 1px solid #dee2e6; padding: 0.75rem; vertical-align: top;">{{ comment.date|date("D, m/d/Y - H:i") }}</td>
    +                          <td style="border: 1px solid #dee2e6; padding: 0.75rem; vertical-align: top;"><strong>Comment from customer:</strong> <br />{{ comment.comment|raw }}</td>
    +                        {% endif %}
    +                      </tr>
    +                    {% endfor %}
    
    +++ b/modules/order/templates/commerce-order--user.html.twig
    @@ -33,6 +34,34 @@
    +            {% for comment in order_comments %}
    +              <tr style="border-bottom: 0.0625rem solid #d3d4d9; color: #232429; background: #fff;">
    +                {% if comment.type == 'commerce_order.comment.to_customer' %}
    +                  <td style="border: 1px solid #dee2e6; padding: 0.75rem; vertical-align: top;">{{ comment.date|date("D, m/d/Y - H:i")}}</td>
    +                  <td style="border: 1px solid #dee2e6; padding: 0.75rem; vertical-align: top;"><strong>Comment to customer:</strong> <br />{{ comment.comment|raw }}</td>
    +                {% elseif comment.type == 'commerce_order.comment.from_customer' %}
    +                  <td style="border: 1px solid #dee2e6; padding: 0.75rem; vertical-align: top;">{{ comment.date|date("D, m/d/Y - H:i") }}</td>
    +                  <td style="border: 1px solid #dee2e6; padding: 0.75rem; vertical-align: top;"><strong>Comment from customer:</strong> <br />{{ comment.comment|raw }}</td>
    +                {% endif %}
    +              </tr>
    +            {% endfor %}
    

    3. Why are we changing the comment output from {{ comment }} to {{ comment|raw }} (and even for the existing admin comments)? Personally I think that comments should be only plaintext and I do not see a reason for this change. It can probably open some vulnerabilities if not handled correctly.

    4. As this patch is pretty large, I think it would be great if we can move it to MR instead, so that reviews/comments/progress is easier and more transparent.

  • 🇺🇦Ukraine khiminrm

    Added small fix for the cases if the customer comment contains apostrophes and when we go back to edit the comment, so wouldn't have &#039; instead of '.

  • 🇺🇦Ukraine khiminrm

    One more small fix to remove the <br /> on edit a comment

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 5.7
    last update 7 months ago
    Patch Failed to Apply
  • Merge request !260Convert #34 to MR → (Open) created by abx
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 7 months ago
    685 pass, 50 fail
  • Pipeline finished with Failed
    7 months ago
    Total: 522s
    #177977
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 7 months ago
    692 pass, 48 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 7 months ago
    692 pass, 48 fail
  • Pipeline finished with Failed
    7 months ago
    Total: 472s
    #177999
  • Pipeline finished with Failed
    7 months ago
    Total: 622s
    #178016
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 7 months ago
    784 pass, 4 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 7 months ago
    784 pass, 4 fail
  • Pipeline finished with Canceled
    7 months ago
    Total: 28s
    #178413
  • Pipeline finished with Failed
    7 months ago
    Total: 485s
    #178414
  • Status changed to Needs review 6 months ago
  • 🇮🇳India vipin.j

    Re-rolling patch from #34 for release commerce 8.x-2.39

  • 🇮🇱Israel jsacksick

    A bit of scope creep here, I'll probably create a separate issue to focus on the checkout pane in checkout as this is a bit hard to review.
    The patch here for example dispatches an event on pane submission, but the user could go back and edit the comment?

    I haven't tested the patch manually, but it doesn't seem that editing the comment is supported.
    I'm thinking we should store the comment in the order data for example, and only record the log on checkout completion / order placement.

  • 🇮🇳India vipin.j

    Here is the updated patch from the reference of #36, after the changes introduced & committed from #38 into Commerce Core.

  • 🇬🇧United Kingdom cjd4001

    I'm getting following error after installing patch 39 (previous patches not patching with my version of commerce 2.40.0 and drupal 10.3.6

    TypeError: Drupal\commerce_log\EventSubscriber\OrderEventSubscriber::__construct(): Argument #2 ($order_receipt_mail) must be of type Drupal\commerce_order\Mail\OrderReceiptMailInterface, Drupal\symfony_mailer\MailManagerReplacement given, called in /home/picksorg/dev1124/core/lib/Drupal/Component/DependencyInjection/Container.php on line 261 in Drupal\commerce_log\EventSubscriber\OrderEventSubscriber->__construct() (line 40 of /home/picksorg/dev1124/modules/contrib/commerce/modules/log/src/EventSubscriber/OrderEventSubscriber.php).

    any help / pointers gratefully received as client strongly relies on this functionality which has stopped working since upgrades.

  • 🇮🇳India vipin.j

    Re rolling patch #39 for Commerce Core '3.0.x' compatibility.

Production build 0.71.5 2024