Support » Plugin: WooCommerce PDF Invoices & Packing Slips » i want to generate pdf from api

  • Resolved royalnavneet

    (@royalnavneet)


    Hello is it possible to generate pdf from api or any anyendpoint like i apps a url with orderid and return get pdf file .

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Ewout

    (@pomegranate)

    We currently don’t have anything in place to supply the PDF via an API endpoint.
    If you have the order key (which you can retrieve via the regular WC API), and enable the “Allow guest access” option in the Status tab of the PDF Invoice settings, you can download the PDF with a direct link. The URL should be formatted like this:

    yoursite.com/wp-admin/admin-ajax.php?action=generate_wpo_wcpdf&document_type=invoice&order_ids=ORDER_ID&order_key=ORDER_KEY

    ORDER_ID is the WooCommerce Order ID (numeric)
    ORDER_KEY is the unique key that WooCommerce assigns each order (looks like this: wc_order_AyaQuu1Xpfmua)

    Hope that helps!

    Thread Starter royalnavneet

    (@royalnavneet)

    Thank you so much

    Plugin Author Ewout

    (@pomegranate)

    to be complete: you can fetch the ORDER_KEY from the order with:

    
    $order->get_order_key();
    

    the order_key is also included in the regular WC REST API response.

    Hello Ewout,

    I am trying to do this. I have activated “Allow guest access” option in the Status tab, but I still receive the message “You do not have enough permissions..” when I try to load invoices from an external App via URL. Any option?

    Thanks!!

    Plugin Author Ewout

    (@pomegranate)

    Did you include the order key in the URL, and can you verify that the key is correct/corresponds with the order that belongs to the invoice?
    Note that this will only work for single invoices, not bulk exports.

    Solved. Thank you.

    I was using it incorrectly.

    • This reply was modified 2 years, 2 months ago by alfredohina.
    • This reply was modified 2 years, 2 months ago by alfredohina.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘i want to generate pdf from api’ is closed to new replies.