In WooCommerce I need to modify the thankyou.php page [closed]

In the thankyou.php template there is an action showing the section marked in red in the image.
The problem is the caption/title “Our Bank Detals” should be above the description not beneath.

screen-dump

The code in thankyou.php that create this section is:

<?php do_action( 'woocommerce_thankyou_' . $order->payment_method, $order->id ); ?>

The above action must point to some code in some other file, which I hope I can modify using a hook in my funcitons.php.
I need help 🙂

thankyou.php is located:

..wp-content/plugins/woocommerce/templates/checkout/thankyou.php

I’ve copied it to my child-theme folder I it is necessary to edit it directly

2 Answers
2

I ended up inserting the payment description.
(the one you specify in the woocommerce settings in the WordPress backend)

The “native” build-in woocommerce payment-text is static and doesn’t relates to the actual selected payment method. 🙁

I did this by modifying the woocommerce template file:

1: Copy this template file:

..wp-content/plugins/woocommerce/templates/checkout/thankyou.php

to

your-theme-folder/woocommerce/checkout/thankyou.php

2: Replace this line
removeline

with this code:

<?php
    if ( $available_gateways = WC()->payment_gateways->get_available_payment_gateways() ) {
        foreach ( $available_gateways as $gateway ) {
            if ( $gateway->title == $order->payment_method_title) { 
                echo '<div> <h2>Payment<h2/> </div>';
                echo $gateway->payment_fields();
            }
        }
    }
?>

(my first real PHP code, so I wouldn’t be surprised if you could be done smarter ;-))

Result (page in danish):
screendump

The downside of this approach is that if WooCommerce one day update this template you need to remember to update it yourself!

Leave a Comment