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

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