@prefix sioc: <http://rdfs.org/sioc/ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix content: <http://purl.org/rss/1.0/modules/content/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://lhero.org/?post_type=lh-portfolio&#038;p=146949>
  a sioc:Post ;
  dc:title "REST API & Admin Interface" ;
  dcterms:identifier 146949 ;
  dc:modified "2026-09-01T16:35:39Z"^^xsd:dateTime ;
  dc:created "2026-09-01T16:35:39Z"^^xsd:dateTime ;
  sioc:link <https://lhero.org/portfolio/lh-woocommerce-invoicing/rest-api-admin-interface/> ;
  sioc:has_creator <https://lhero.org/author/1015845/#account> ;
  sioc:has_container <https://lhero.org/#posts> ;
  content:encoded """
<h2 class="wp-block-heading">REST endpoint</h2>



<p class="wp-block-paragraph"><code>GET /wp-json/lh-woocommerce-pdf-invoicing/v1/invoice/{order_id}</code> generates and streams a PDF invoice for the specified order.</p>



<p class="wp-block-paragraph"><strong>Authentication:</strong> Standard WordPress REST API authentication &#8212; cookie+nonce (<code>?_wpnonce=...</code>), application passwords, or any other WP REST auth method.</p>



<p class="wp-block-paragraph"><strong>Permission:</strong></p>



<ul class="wp-block-list">
<li>Users with <code>install_plugins</code> capability (admins) may download any order&#8217;s invoice.</li>
<li>Logged-in customers may download invoices for their own orders only.</li>
<li>Unauthenticated requests are rejected with HTTP 401.</li>
</ul>



<p class="wp-block-paragraph"><strong>Response:</strong> Binary PDF (<code>Content-Type: application/pdf</code>) with <code>Content-Disposition: attachment</code>.</p>



<figure class="wp-block-table"><table><thead><tr><th>HTTP Status</th><th>Reason</th></tr></thead><tbody><tr><td>401</td><td>Not logged in</td></tr><tr><td>403</td><td>Logged in but order belongs to a different customer</td></tr><tr><td>404</td><td>Order ID not found</td></tr></tbody></table></figure>



<h2 class="wp-block-heading">Admin interface</h2>



<h3 class="wp-block-heading">PDF Invoice metabox</h3>



<p class="wp-block-paragraph">A <strong>PDF Invoice</strong> metabox appears in the side column of every WooCommerce order edit screen, containing a <strong>Download PDF Invoice</strong> button that links directly to the REST endpoint with a <code>wp_rest</code> nonce. Requires the <code>install_plugins</code> capability.</p>



<h3 class="wp-block-heading">Order actions dropdown</h3>



<p class="wp-block-paragraph">A <strong>Download PDF Invoice</strong> entry is available in the WooCommerce order actions dropdown. Selecting it and clicking <strong>Update</strong> redirects the admin to the REST download URL. Requires the <code>install_plugins</code> capability.</p>



<h3 class="wp-block-heading">My Account orders screen</h3>



<p class="wp-block-paragraph">A <strong>Download Invoice</strong> button appears alongside the standard order action buttons on the customer&#8217;s My Account &#8594; Orders screen, visible to the order&#8217;s own customer only.</p>



<h2 class="wp-block-heading">Constants</h2>



<figure class="wp-block-table"><table><thead><tr><th>Constant</th><th>Description</th></tr></thead><tbody><tr><td><code>LH_WOOCOMMERCE_PDF_INVOICING_VERSION</code></td><td>Current plugin version string</td></tr><tr><td><code>LH_WOOCOMMERCE_PDF_INVOICING_FILE</code></td><td>Absolute path to the main plugin file</td></tr><tr><td><code>LH_WOOCOMMERCE_PDF_INVOICING_DIR</code></td><td>Absolute path to the plugin directory (trailing slash)</td></tr></tbody></table></figure>
"""^^rdf:XMLLiteral ;
  sioc:content """
REST endpoint



GET /wp-json/lh-woocommerce-pdf-invoicing/v1/invoice/{order_id} generates and streams a PDF invoice for the specified order.



Authentication: Standard WordPress REST API authentication &#8212; cookie+nonce (?_wpnonce=...), application passwords, or any other WP REST auth method.



Permission:




Users with install_plugins capability (admins) may download any order&#8217;s invoice.
Logged-in customers may download invoices for their own orders only.
Unauthenticated requests are rejected with HTTP 401.




Response: Binary PDF (Content-Type: application/pdf) with Content-Disposition: attachment.



HTTP StatusReason401Not logged in403Logged in but order belongs to a different customer404Order ID not found



Admin interface



PDF Invoice metabox



A PDF Invoice metabox appears in the side column of every WooCommerce order edit screen, containing a Download PDF Invoice button that links directly to the REST endpoint with a wp_rest nonce. Requires the install_plugins capability.



Order actions dropdown



A Download PDF Invoice entry is available in the WooCommerce order actions dropdown. Selecting it and clicking Update redirects the admin to the REST download URL. Requires the install_plugins capability.



My Account orders screen



A Download Invoice button appears alongside the standard order action buttons on the customer&#8217;s My Account &#8594; Orders screen, visible to the order&#8217;s own customer only.



Constants



ConstantDescriptionLH_WOOCOMMERCE_PDF_INVOICING_VERSIONCurrent plugin version stringLH_WOOCOMMERCE_PDF_INVOICING_FILEAbsolute path to the main plugin fileLH_WOOCOMMERCE_PDF_INVOICING_DIRAbsolute path to the plugin directory (trailing slash)
""" ;
  sioc:topic <https://lhero.org/lh_portfolio-type/doc-section/>, <https://lhero.org/?taxonomy=author&term=cap-1015845> .

<https://lhero.org/author/1015845/#account> rdfs:seeAlso <https://lhero.org/author/1015845/?feed=lhrdf&format=turtle> .
<https://lhero.org/lh_portfolio-type/doc-section/> rdfs:seeAlso <https://lhero.org/lh_portfolio-type/doc-section/?feed=lhrdf&format=turtle> .
<https://lhero.org/?taxonomy=author&term=cap-1015845> rdfs:seeAlso <https://lhero.org/?taxonomy=author&term=cap-1015845&feed=lhrdf&format=turtle> .
