Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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 #2908196: Add ability to add an order comment.
Comment | File | Size | Author |
---|---|---|---|
#34 | interdiff_33_34.txt | 643 bytes | khiminrm |
#34 | 3267366-add-customer-facing-order-comments-34.patch | 38.15 KB | khiminrm |
#33 | interdiff_31_33.txt | 609 bytes | khiminrm |
#33 | 3267366-add-customer-facing-order-comments-33.patch | 38.14 KB | khiminrm |
#31 | interdiff_30_31.txt | 586 bytes | khiminrm |
Issue fork commerce-3267366
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
vipin.j CreditAttribution: vipin.j as a volunteer commentedThe patch is based on #141 with:
- Core version requirement now matches with 8.x-2.29 release.
- Improve presentation of comments added.
- Applies missed coding standards.
Comment #4
Morbus IffInterface review.
Regarding the new checkout pane (customer-checkout-pane-4.png):
Regarding the admin interface (order-adminterface-4.png):
Some other hiccups:
And, finally, to @rszrama:
I agree that this patch currently merges two different functionalities: the ability for admins to add comments to an order that a customer sees ("here's your shipping number!", "this has been delayed!", "your preorder has been canceled!", "I refunded your shipping. Thanks!", etc.), and the ability for customers to add data for administrators (for clarity, I'll call these "checkout comments").
I need both in my sites. I half-agree that "checkout comments" COULD be implemented (more flexibly) by a custom field. For example, if I'm selling school books and I need to know what school you go to, I'd add a "School" custom field, absolutely. And, sure, I suppose I could add a generic "Checkout comments" field too, but now we're splitting a single mentality ("order comments") into two separate implementations (the log-based "admin comments" and "customer-facing comments", and then a field-based "checkout comments").
For me, the "compromise" is what you've already suggested: the default "Order comments" checkout pane (provided by this patch) should be disabled by default. This will then allow the user to choose the merged all-in-a-log functionality for generic comments, while still allowing them to create custom-order-fields ("School name:") for more controlled pieces of operable data.
Comment #5
Morbus IffMy suggestion above:
I'm thinking we can expand on this to support both approaches.
What would be nice for the most flexibility is some way for the themer/site owner to decide if they want the entire order receipt (i.e., what the suggested defaults above are) or if they only want to send comments (i.e., what patch #2 does with emailed-comment-4.png does). My thought here is that whenever an admin chooses to email the customer with an order comment, a new variable is added to the order receipt template called "is_emailed_comment" (or something). This would then allow a themer/site owner to customize their own commerce receipt template to NOT send the non-comment parts of the commerce receipt, something like:
This allows Commerce to support both approaches: full order receipts with comments (i.e. what I think the defaults should be) and "only comments emailed" (i.e., what patch #2 does with emailed-comment-4.png does). But it'd do it all with the existing commerce receipt template, not a new template (like patch #2 does).
Comment #6
vipin.j CreditAttribution: vipin.j as a volunteer commentedThe previous patch added #2 was based on #141 which was way different then the last commit 12cb8ca by @mglaman
This patch is refined version of #141 as the requirements of this issue is now fulfilled by extending the functionality from commit 12cb8ca
Comment #8
Morbus IffPatch 6 (P6) makes some substantial changes to the original patch 2 (P2).
commerce-order-receipt.html.twig
for the email, which now supports showing order comments if they exist. A new twig file has been added calledcommerce-log-order-comments.html.twig
which, by default, is just a copy of that existing order receipt. With this new twig file, it's possible to move your comments to the top of the email or to reproduce the behavior of P2 (by wiping out everything else and using only the first array item of theorder_comments
variable).To push back on a @rszrama suggestion: If the checkout pane just has a textarea in it, I don't see why its wrapper element should be a fieldset. Can we not just make this a container div? That's been implemented in this patch (customer-checkout-pane-6.png), and I don't like it. Primarily, every other place that a comment form item appears, they look "better" in a fieldset. On customer-checkout-pane-review-6.png, it looks "better" because all the other data is in a fieldset, on order-adminterface-6.png a fieldset is used for the comment because we've got radios, etc. I'm thinking that we should continue to use a fieldset, named "Comments", but leave the textfield unlabeled (similar to order-adminterface-6.png).
For those using P2 in prod, there are potentially breaking changes:
Comment #9
vipin.j CreditAttribution: vipin.j as a volunteer commentedFixes testbot errors generated with patch #6
Comment #10
bobburns CreditAttribution: bobburns commented#9 works great - badly needed missing feature. I had to install manually - and I am guessing it will soon be committed to Commerce Core
It is disabled by default
Enable after patching at /admin/commerce/config/checkout-flows/manage/default?destination=/admin/commerce/config/checkout-flows
a.k.a /admin/commerce/config/checkout-flows
Comment #11
ayalon CreditAttribution: ayalon at Liip commentedThanks for the initiative and creating a new issue.
The new patch does not apply to Commerce 2.30 because commerce_log.install File was extended.
Attached an updated patch.
Comment #12
vipin.j CreditAttribution: vipin.j as a volunteer commentedHere is another refined version of #9 patch. Contains improvements and noticeable bug fixes.
Comment #13
vipin.j CreditAttribution: vipin.j as a volunteer commentedDue to the recent 8.x-2.x-dev version upgrade with #12, which now causing patch application failure on production release.
the issue was with the file
modules/log/commerce_log.install
, So I removed the snippet which does Drupal role permission grant withhook_install()
Alternatively we can take care of permission grant with Drupal configurations.
Hope this new patch will be helpful.
Comment #14
Morbus IffReminder ping for review.
Comment #15
jsacksick CreditAttribution: jsacksick at Centarro for Matsmart commentedWe'll try to review this while in Prague.
Comment #16
rinasek CreditAttribution: rinasek at Centarro commentedComment #17
jsacksick CreditAttribution: jsacksick at Centarro for Matsmart commentedHaven't really had time to do a proper review, but the first thing I'm noticing is the checkout pane defined, which should be defined by the commerce_log module rather than defining it from commerce_checkout and have all bunch of checks to ensure commerce_log is enabled.
Also what's done from the OrderReceiptMail could be done via a hook_preprocess_HOOK() implemented by commerce_log, so once again we don't have to check if commerce_log is enabled etc.
Is there a reason for the unrelated test changes too?
Comment #18
vipin.j CreditAttribution: vipin.j as a volunteer commented@jsacksick, Thanks for your response.
We've moved the CustomerCommentsPane class to commerce_log now, as per your valuable suggestion.
But we have
OrderReceiptMail::getOrderComments()
method's dependency across commerce_log and commerce_order modules, as the callback for the same placed in 3 files. moving withhook_preprocess_HOOK
will result in duplication of code statements.Still, I have attached the re-rolled and updated patch, Kindly review.
And yeah, we were facing test case failures while patch submission, which made us to fix them.
Comment #19
abx CreditAttribution: abx commentedWill this patch has a chance to get merged? Or should I continue looking for other method?
Thanks,
Comment #20
vipin.j CreditAttribution: vipin.j as a volunteer commentedThe patch #18 is re-rolled with updates for release ^2.35 compatibility.
Comment #21
vipin.j CreditAttribution: vipin.j as a volunteer commentedSmall tweak in the patch to remove one of the WCAG 2.1 issue.
Comment #22
Lukas von BlarerThis needs a re-roll.
Comment #23
Lukas von BlarerOk, here is a re-roll.
Comment #24
Lukas von BlarerSorry, I forgot to add the new files.
Comment #25
abx CreditAttribution: abx commentedTested #24 with latest dev and works.
Thanks,
Comment #26
nags338228 CreditAttribution: nags338228 as a volunteer commentedHi,
I patched with https://www.drupal.org/project/commerce/issues/3267366 and https://www.drupal.org/project/commerce/issues/2908196 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.
It would be great if anyone can test it please?
Thanks !!
Comment #27
vipin.j CreditAttribution: vipin.j as a volunteer commentedFrom patch #6 we are carrying a deprecated statement which has fixed with the issue #3336658
Re-rolling patch #24 to fix this issue in the patch.
Comment #28
poker10 CreditAttribution: poker10 at ActivIT s.r.o. commentedI 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 (#3166853: How to Add Order Comment and also Allow to notify customer via email?), each other eshop system has such comments (magento, ubercart, prestashop, opencart).
Comment #29
khiminrm CreditAttribution: khiminrm at Centarro commentedI'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?
Comment #30
khiminrm CreditAttribution: khiminrm at Centarro commentedI've fixed the bug from the previous comment.
Comment #31
khiminrm CreditAttribution: khiminrm at Centarro commentedAdded 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.
Comment #32
poker10 CreditAttribution: poker10 at ActivIT s.r.o. commentedThanks 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:
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:
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.
Comment #33
khiminrm CreditAttribution: khiminrm at Centarro commentedAdded small fix for the cases if the customer comment contains apostrophes and when we go back to edit the comment, so wouldn't have
'
instead of'
.Comment #34
khiminrm CreditAttribution: khiminrm at Centarro commentedOne more small fix to remove the
<br />
on edit a comment