Product Icon

WooCommerce Order Barcodes

Generates a unique barcode for each order on your site — perfect for e-tickets, packing slips, reservations and a variety of other uses.

FIxed not loading png of code39 barcode

Code39 barcodes were not loading on my site backend and not embedded well in the mails.

In includes/class-woocommerce-order-barcodes.php I fixed this by replacing lines 464 – 478:

// // Return an image (for emails and frontend order view).
// if ( $image ) {
// $barcode_url = $this->barcode_url( $order_id );

// ob_start();
// echo ”;
// echo ”;
// echo ”;
// /* @phpstan-ignore-next-line */
// require WC_ORDER_BARCODES_DIR_PATH . ‘/templates/barcode-image.php’;
// echo ”;
// echo ”;
// echo ”;
// return ob_get_clean();
// }

by:

// For email/frontend/admin, avoid the PNG endpoint and render inline barcode markup instead.
if ( $image ) {
// In admin and frontend, inline markup works better than the PNG endpoint on this setup.
if ( is_admin() ) {
$barcode_output = ( ‘datamatrix’ === $this->barcode_type ) ? ‘SVG’ : ‘HTML’;
$barcode_markup = $this->barcode_generator->get_generated_barcode( $barcode_text, $barcode_output );

ob_start();
echo ”;
echo ”;
echo ”;
echo $barcode_markup; // phpcs:ignore
echo ” . esc_html( $barcode_text ) . ”;
echo ”;
echo ”;
echo ”;

return ob_get_clean();
}

// For emails/front-end image contexts, embed the PNG directly as base64.
$barcode_png = $this->barcode_generator->get_generated_barcode( $barcode_text, ‘PNG’ );

if ( is_string( $barcode_png ) && ” !== $barcode_png ) {
$barcode_base64 = base64_encode( $barcode_png );

ob_start();
echo ”;
echo ”;
echo ”;
echo ”;
echo ” . esc_html( $barcode_text ) . ”;
echo ”;
echo ”;
echo ”;

return ob_get_clean();
}

// Fallback.
$barcode_output = ( ‘datamatrix’ === $this->barcode_type ) ? ‘SVG’ : ‘HTML’;
$barcode_markup = $this->barcode_generator->get_generated_barcode( $barcode_text, $barcode_output );

ob_start();
echo ”;
echo ”;
echo ”;
echo $barcode_markup; // phpcs:ignore
echo ” . esc_html( $barcode_text ) . ”;
echo ”;
echo ”;
echo ”;

return ob_get_clean();
}

Author

michaelgortergorteradvisie

Current Status

Open

Last updated: March 19, 2026

0 comments

Log in to comment on this feature request.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.