Currently, it is not possible to customize the display title of a payment instance, neither through code nor the UI.
I think this would greatly improve the UX of payment methods, as it gives site builders much more control over how those payment methods are displayed.
Additional features like configurable description/images and so on would be cool as well, but much more work, this is almost trivial.
I'm not sure what the commit policy for Commerce 7.x-1.x is, this should be backwards compatible unless there is a payment method out there that defines a display_title setting that is used for something else. It does introduce two new strings, though.
Alternatively, I could also provide a patch that only contains the check, so payment methods could add this setting on their own.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | commerce-display-title-setting-1806540-21.patch | 2.08 KB | sourabhjain |
| #7 | commerce-display-title-setting-1806540-7.patch | 2.08 KB | berdir |
| #3 | commerce-display-title-setting-1806540-3.patch | 2.18 KB | berdir |
| #3 | saferpay.png | 14.75 KB | berdir |
| #3 | paypal_wps.png | 84.8 KB | berdir |
Comments
Comment #1
berdirHere is the patch.
Comment #2
berdirPer discussion with Ryan, I'll change it to a textarea and run it through filter_xss_admin() to support HTML, like displaying credit card images or something like that.
Comment #3
berdirOk, here is a re-roll that does that.
- Changed textarea
- Uses format_xss_admin()
- Added both a rendered default display title below and the raw html to the description. I'm not sure what to do with that (keep either of them or both), because the problem is that while simple display titles work with with just the part in the description, it gets very ugly with e.g. Paypal WPS. See attached screenshots.
Comment #4
bessone commentedWhich patch will be committed?
Comment #5
bessone commentedI noticed that in the display order in the administration i do not see the custom name, but only the original name, any advice?
In the commerce_payment_order view i see:
Display the payment method using the following title
but also with the last option, i can't see the custom title in this admin view.
Comment #6
elgandoz commentedI have the same problem with the administration view, it's not possible to show the custom title in the payment page, you just see the original title.
Comment #7
berdirRe-roll of the previous patch.
Yes, the view needs to be updated as well.
Comment #8
rbrownellHas this been committed yet?
EDIT: Given how the patch applied correctly to the current dev version I am going to say it probably wasn't. What needs to be done to get this committed? Currently I am working on testing it if that helps at all.
-R
Comment #9
rszrama commentedIt would need to be translatable.
Comment #10
rbrownellThis Patch 7 does not modify the title for PayPal WPS. It looks like that if the module does not already overwrite the title this method works. It seems logical that the PayPal module should follow the method here to modify the title and simply have any fancy graphics and text built into the rule so that can be overridden as opposed to the current hard coded, very difficult to change without patching the module, method.
Would you recommend a different Patch 3 over Patch 7?
EDIT: Patch 7 works when the following is commented out of the Commerce PayPal WPS Module.
-R
Comment #11
rszrama commentedNote that the reason PayPal WPS does this is #1518452: Payment method display titles with theme functions initialize the wrong theme with modules that use entity_get_info() early in bootstrap.
Comment #12
rbrownellThis may not be relevant here but when I was looking for how to customize the display of the payment types I kept coming to this page... For information on how to do with with template.php in your theme read #2062337: Remove Logos.
Comment #13
bigEwok commentedHi, i applied this patch but i have a problem in /commerce/orders.
I created 2 rules with the same method of paiement. It works in the checkout, the user may choose one of these 2 rules.
But in /commerce/orders i can't display the custom title, only the title of the method of paiement.
So i can't differentiate the choice of the user, that is the problem.
If somebody knows, thanks.
Comment #14
zmove commented+1 to this. The #7 patch should be commited ASAP (even if not perfect, it's better than nothing (that's what we have today)).
Comment #15
heathdutton commented+1 for #7.
Comment #16
joelpittetWrapping the result in t() on the way out would work but variables going into t() is a no-no generally. Is there another approach to making that work or is that the only way?
Setting to CNW from #9
Comment #17
nico.knaepen commentedThe only way to work around the t() issue with variables is to foresee a variable per active language.
Comment #18
nico.knaepen commentedI've created a new module where you are able to alter the display title's of the source language and foresee a translation for other languages. https://www.drupal.org/project/commerce_payment_alter
Comment #19
andren commentedThanks Nico #18 Worked like a Charm!
Comment #20
daletrexelI have also made use of Commerce Payment Alter (thanks Nico!), however, in my trials, PayPal WPS continues to override any attempt to change the title, even with the module in use. The module is working for me as described for Commerce Square and Commerce Custom Offline Payment.
It would be nice to not need an extra module to be able to customize (and internationalize) payment option titles, and it would be especially nice to not allow payment methods to hard-code their own titles and styling, like PayPal WPS seems intent on doing.
Comment #21
sourabhjainRerolled the patch against latest 7.x-1.x branch.