This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Show Download invoice PDF Link for WooCommerce PDF Invoices & Packing Slips in Thank you page with if condition. | |
// Original gist: https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/download-link-on-the-thank-you-page/ | |
// credits to David Anderson (@davidanderson) and Ewout (@pomegranate) | |
// add it to fuctions.php in your child theme (WordPress) | |
add_filter('woocommerce_thankyou_order_received_text', 'wpo_wcpdf_thank_you_link', 10, 2); | |
function wpo_wcpdf_thank_you_link( $text, $order ) { | |
if ( is_user_logged_in() ) { | |
$pdf_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=' . $order->get_id() . '&my-account'), 'generate_wpo_wcpdf' ); | |
$text .= '<p><a href="'.esc_attr($pdf_url).'">Download a printable invoice / payment confirmation (PDF format)</a></p>'; |