Woocommerce PDF Invoice plugin x Barcode Generator for Woocommerce

This topic has 4 replies, 2 voices, and was last updated 1 months, 4 weeks ago ago by Luca Rossi

  • Avatar: Filip
    Filip
    Participant
    July 4, 2025 at 20:04

    Dear 8Theme Support Team,

    I am writing to you regarding an integration challenge we are facing with your product.

    We are actively using the “Barcode Generator for WooCommerce”, a third-party plugin, which successfully adds the capability to display EAN codes on our single product pages. The EAN values for each product are managed and stored within a product meta field, specifically accessible via an HTML input field named bargeno_meta_barcode (e.g., <input type="text" name="bargeno_meta_barcode" class="text" value="123456789">).

    Our primary objective now is to extend this functionality to our Woocommrce PDF invoices, so that the corresponding EAN barcode is displayed next to each product line item on the invoice itself.
    We have attempted to achieve this by writing a custom PHP snippet. This snippet is designed to retrieve the EAN value directly from the bargeno_meta_barcode field (provided by the BGW plugin) and then utilize TCPDF’s barcode generation capabilities within the CreateInvoice method of the WooPdfInvoice class (which is part of WooCommerce PDF Invoice). However, despite our efforts, the barcodes are currently not appearing on the generated PDF invoices.

    To assist with troubleshooting, we can provide the following:
    • Details on the HTML input field (<input type="text" class="short" style="" name="bargeno_meta_barcode" id="bargeno_meta_barcode" value="123456789" placeholder="Zadajte vlastnú hodnotu EAN">) where the EAN value is entered.
    • The tcpdf_barcodes_1d.php file, which contains the TCPDFBarcode class (a common library for 1D barcode generation that we are using in conjunction).
    • The woo-pdf-invoice.class.php file, which outlines the WooPdfInvoice class that handles our PDF invoice generation.
    • The specific PHP code snippet we have developed based on the bargeno_meta_barcode field, which is intended to display the barcode on the invoice.

    Our Current Challenge: We understand that neither the Barcode Generator for WooCommerce nor the WooCommerce PDF Invoice plugins are direct products of yours. Unfortunately, we do not possess a direct purchase code for the Woocommerce PDF Invoice plugin, which has made our attempts to contact RightPress support directly for assistance challenging.

    Could you please guide us on the correct and supported method to display the dynamically generated EAN barcodes (sourced from “Barcode Generator for WooCommerce” plugin) on each product line item within the Woocommerce PDF Invoices?

    Here is the php snippet we tried to use in the woo-pdf.invoice.class.php – a file that handles invoice structure – under function public function CreateInvoice()

    // Retrieve barcode value from product meta
    $barcode_value = $_product->get_meta('bargeno_meta_barcode');
    
    if (!empty($barcode_value)) {
        // Assuming EAN13 for standard product barcodes, adjust to 'EAN8' if necessary
        $barcode_type = 'EAN13';
        // Remove non-numeric characters and validate length for EAN13 (12 or 13 digits)
        $cleaned_barcode_value = preg_replace('/[^0-9]/', '', $barcode_value);
    
        if (strlen($cleaned_barcode_value) == 12 || strlen($cleaned_barcode_value) == 13) {
            // Define barcode position and dimensions
            $barcode_x = 45; // X coordinate, slightly indented like meta information
            $barcode_y = $this->GetY() + 5; // Y coordinate, below the previous element (meta/images), add some padding
            $barcode_width = 70; // Width of the barcode
            $barcode_height = 15; // Height of the barcode
            $font_size_barcode = 8; // Font size for the barcode text
    
            // Set font for barcode text
            $this->SetFont('helvetica', '', $font_size_barcode);
            // Set TCPDF barcode styles
            $style = array(
                'border' => false,
                'padding' => 'auto',
                'fgcolor' => array(0, 0, 0), // Black foreground
                'bgcolor' => array(255, 255, 255), // White background
                'text' => true, // Show the barcode value as text below the barcode
                'font' => 'helvetica',
                'fontsize' => $font_size_barcode,
                'stretchtext' => 4,
            );
    
            // Draw the barcode
            $this->write1DBarcode(
                $cleaned_barcode_value,
                $barcode_type,
                $barcode_x,
                $barcode_y,
                $barcode_width,
                $barcode_height,
                '',
                $style,
                'N' // No alignment, N for next line
            );
    
            // Update the Y position for the next elements (e.g., next product row)
            $y = $this->GetY() + 5; // Add some padding after the barcode
        } else {
            // Optional: Log if barcode value length is not valid for EAN13/EAN8
            error_log("WooPDFInvoice Barcode Error: Invalid barcode value length for product ID " . $_product->get_id() . ". Value: " . $barcode_value);
        }
    }

    Thank you for your time and consideration.

    Best regards,
    Filip

    Please, contact administrator
    for this information.
    3 Answers
    Avatar: Justin
    Luca Rossi
    Support staff
    July 5, 2025 at 17:39

    Dear @Filip,

    Thank you for reaching out.

    Implementing the requested functionality would require extensive custom coding, which involves significant development time and debugging. As such, it falls outside the scope of our standard support services.

    For any customizations beyond the default features, we kindly invite you to submit a request through our Customization Panel at: https://www.8theme.com/account/#etheme_customization_panel. Please note that customization services may incur additional charges.

    We appreciate your understanding.

    Best regards,
    The 8Theme Team

    Avatar: Filip
    Filip
    Participant
    July 7, 2025 at 20:06

    Hi Luca,
    having clicked on the link you shared, I don’t see any option or section to send my quote. I’m simply redirected to the account dashboard with account/#etheme_customization_panel as the uri.

    Best regards,
    Filip

    Avatar: Justin
    Luca Rossi
    Support staff
    July 8, 2025 at 05:25

    Dear @Filip,

    We kindly ask you to reach out using the email provided in the Private Content Area.

    Thank you for your cooperation.

    Best regards,
    The 8Theme Team

    Please contact administrator
    for this information.
  • Viewing 4 results - 1 through 4 (of 4 total)

The issue related to '‘Woocommerce PDF Invoice plugin x Barcode Generator for Woocommerce’' has been successfully resolved, and the topic is now closed for further responses

Helpful Topics

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.