Completed order email has incorrect payment method title
Closed this issue · 7 comments
Describe the bug
Since #9647 was merged, the order confirmation emails include added content for the payment method title, which shouldn't be there.
To Reproduce
- Create a one-page checkout. I'm using shortcode
[woocommerce_checkout]
. - Make a test payment and have the email sent to yourself.
- Note that the payment method listed in the email has a bunch of unnecessary text added to it.
- Important to note that this problem doesn't happen when re-sending the order confirmation email from the order editing page.
Screenshots
This is how the relevant part of an email for a test purchase on my staging environment looks now.
Additional context
It seems that is_checkout()
here here is returning true
because the email is being sent from the checkout page. Perhaps an extra check can be added to prevent this happening for emails?
For posterity, I added some insight here: #9647 (comment)
I was trying to find a different approach to implement in the get_title()
method, like checking if we're in an email context with something like
if ( did_action( 'woocommerce_email_header' ) ) {
return $title;
}
But that didn't seem to work. The payment method from the email is retrieved from the order, and it is set via the WC_Order->set_payment_method()
method.
It looks like we might need to revisit the implementation of the "Test mode" badge on the shortcode checkout.
I'm not sure if we should implement a change in WC Core (to have better compatibility) or find another way of rendering the label (via JS, for example).
In the meantime, I added this filter that will land in WooPayments 8.6.0: #9783
A workaround to this issue with email templates could be achieved with the following code, using the filter mentioned in the previous paragraph:
add_filter( 'wcpay_checkout_use_plain_method_label', 'is_ajax' );
CCing @pierorocca & @FangedParakeet on the above comment as well ☝
I'll catch up with you on DM to better understand how the badge is associated with the payment method label.
There is a report on this in 8658095-zen where Kadence WooCommerce Email Designer (a 3pd plugin) is displaying something similar.
Here is a screenshot of what the customers see:
And a preview of the email, on the customizer plugin:
cc. @frosso as discussed via DM
@morepurplemorebetter thank you again for the discussion and for logging the ticket!
We discussed within the team, and we'll be reverting the "Test mode" badge on shortcode checkout in the next patch release.
So you can ignore the wcpay_checkout_use_plain_method_label
filter, for now.
We'll bring it back in a safer way in a future release.
Thanks for your patience!
@frosso thank you for taking the time to fix this issue and responding so kindly.
I'm looking forward to the next WooPayments version with which I can hopefully clean up my functions.php
from its haphazard temporary patches.
#9073954-zen This is in the email as well as the order list page:
It occurs when a Afterpay or Klarna order fails:
Full Size: https://d.pr/i/qIPT1p