I am trying to add a custom dynamic QR code image from order variables to Woocommerce thankyou page.
The code what I am trying to add into functions.php file is below:
add_action( 'woocommerce_thankyou', 'display_order_received_qr_code', 10, 1 );
function display_order_received_qr_code( $order_id ) {
$order = wc_get_order($order_id);
printf('<img class="qrcodecz" alt="QR platba" src="%s" />',
add_query_arg( array(
'accountNumber' => '2202681982',
'bankCode' => '2010',
'amount' => $order->get_subtotal(),
'currency' => 'CZK',
'vs' => $order->get_order_number(),
'message' => 'svetvramu.cz',
'size' => 200,
), 'https://api.paylibo.com/paylibo/generator/czech/image' ),
);
}
Unfortunately it is not working, nothing appeared on my thank you page. I have read some forums or advices (for example this link: https://avada.io/woocommerce/docs/customize-thank-you-page.html) and I suppose the code what I am using is correct.
In the same file (functions.php) I am using more actions and all of them worked well.
Thank you for any hint!
Try the following corrections in your function