How to auto-print WooCommerce shipping labels
Take the shipping-label PDF your WooCommerce shipping plugin produced and print it through the API. PrintBase does not replace that plugin.
For WooCommerce stores with a thermal label printer at the bench
Overview
Label files in WooCommerce usually come from a shipping plugin, not from WooCommerce core. PrintBase does not integrate those plugins and does not buy postage. When your code can see the label PDF — a path, a media library file, or a URL — it can send that file to the bench printer.
Hook the moment the label is stored, not the moment the order is created. A 4 by 6 PDF should be content_type pdf. If the shipping plugin only gives you ZPL, send content_type raw instead of wrapping the ZPL in a PDF. The two are different jobs.
Idempotency-Key wc-label-{orderId}-{shipmentId} stops a double click in wp-admin from printing two labels. The agent must run on the computer that has the label printer installed.
Integration steps
- 01
Find where the label file lands
Read the shipping plugin's order meta or filesystem path. Do not scrape the admin HTML.
- 02
Match the payload to the file
PDF labels use content_type pdf. Raw ZPL or EPL from the plugin uses content_type raw. Do not base64 a PDF and mark it raw.
- 03
Target the label queue
printer_code is the thermal printer, not the office laser you use for packing slips.
- 04
POST from the server
The browser button in wp-admin should call your PHP endpoint, which holds the API key and calls PrintBase.
- 05
Mark the shipment printed only after completed
HTTP 201 means queued. Poll the job or use a paid-plan webhook before you tell staff the label is done.
PHP
<?php
// WooCommerce label PDF already written by the shipping plugin
$payload = [
'printer_code' => (int) getenv('PRINTER_CODE'),
'content_type' => 'pdf',
'content' => base64_encode(file_get_contents($labelPath)),,
'copies' => 1,
];
$ch = curl_init('https://api.printbase.cloud/v1/print-jobs');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('PRINTBASE_API_KEY'),
'Content-Type: application/json',
'Idempotency-Key: ' . 'wc-label-' . $orderId,
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$body = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) >= 300) {
throw new RuntimeException($body);
}
$job = json_decode($body, true); // id, status=queued
Details for this setup
PDF path for a WooCommerce 4×6 label
Use content_type pdf and exactly one of content (standard base64) or content_url (an http or https URL the agent can download). A private file must be fetched by your server and sent as base64, or exposed as a short-lived URL. On Windows the agent asks a PDF app to print to the named queue; if none is registered, the failure text names Adobe Reader or SumatraPDF as examples. macOS and Linux use lp.
Plugin files are often private
A path inside wp-content is not a content_url the agent can fetch. Read the file in PHP and send content. Use content_url only for a URL the agent can GET.
Questions
Which shipping plugins are supported?
None specifically. If you can read the PDF or ZPL the plugin saved, you can print it. PrintBase does not ship plugin adapters.
Can I print the packing slip on the same printer?
Yes, as a second job, if that printer's driver can handle the slip. Many thermal printers want a 4 by 6 label only.
The barcode will not scan.
If you sent a PDF, the driver rasterized it. When the carrier gave you ZPL, send that ZPL as raw instead. See the blurry-barcode guide.
Does the free plan cover a day's labels?
100 jobs a month on one computer. Above that you need a paid plan. Each label is one job.
Free plan: 100 jobs a month on one computer, no card.