Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed order email has incorrect payment method title #9779

Closed
morepurplemorebetter opened this issue Nov 21, 2024 · 7 comments · Fixed by #9800
Closed

Completed order email has incorrect payment method title #9779

morepurplemorebetter opened this issue Nov 21, 2024 · 7 comments · Fixed by #9800
Labels
focus: checkout payments type: bug The issue is a confirmed bug.

Comments

@morepurplemorebetter
Copy link

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

  1. Create a one-page checkout. I'm using shortcode [woocommerce_checkout].
  2. Make a test payment and have the email sent to yourself.
  3. Note that the payment method listed in the email has a bunch of unnecessary text added to it.
  4. 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.
Image

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?

@frosso
Copy link
Contributor

frosso commented Nov 21, 2024

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' );

@frosso
Copy link
Contributor

frosso commented Nov 21, 2024

CCing @pierorocca & @FangedParakeet on the above comment as well ☝

@pierorocca
Copy link
Contributor

I'll catch up with you on DM to better understand how the badge is associated with the payment method label.

@raifd
Copy link

raifd commented Nov 22, 2024

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:

Image

And a preview of the email, on the customizer plugin:

Image

cc. @frosso as discussed via DM

@frosso
Copy link
Contributor

frosso commented Nov 23, 2024

@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!

@morepurplemorebetter
Copy link
Author

@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.

@kaushikasomaiya
Copy link

kaushikasomaiya commented Nov 26, 2024

#9073954-zen This is in the email as well as the order list page:
It occurs when a Afterpay or Klarna order fails:

https://d.pr/i/qIPT1p
Full Size: https://d.pr/i/qIPT1p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: checkout payments type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants