Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter bavington

    (@bavington)

    Sorry, with a little more persistance, I managed to work it out:

    <a href="<?php echo wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=packing-slip&order_ids=' . $order->id ), 'generate_wpo_wcpdf' ); ?>">
    		Print PDF Packing Slip</a>
    Plugin Contributor Ewout

    (@pomegranate)

    Hello James,
    That code will only work for logged in users (which I realize may be no problem in your case), so you may want to build in an extra check. This is also covered in the FAQ, you can simply replace invoice in the url with packing-slip:

    How can I add a download link to the invoice on the Thank you page?
    You can do this with an action in your theme’s functions.php (Some themes have a “custom functions” area in the settings). Note that due to security restrictions, this will only work for registered/logged in users!

    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->id . '&my-account'), 'generate_wpo_wcpdf' );
            $text .= '<p><a href="'.esc_attr($pdf_url).'">Download a printable invoice / payment confirmation (PDF format)</a></p>';
        }
        return $text;
    }

    alternatively, you can hook this text to the woocommerce_thankyou action, see this thread on the support forum.

    Hope that helps!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding a Print PDF/Packing Slip button to the order confirmation page’ is closed to new replies.