Skip to content

Developer notes

Back to the overview

All classes live in Tygh\Addons\KvBarcodeLabels:

Class Purpose
Gtin GS1 check digit, validation, comparison key, GTIN building from a prefix (pure functions).
Symbology Chooses EAN-13, UPC-A, EAN-8, Code 128 or QR for a value (pure).
Encoder\Linear EAN-13 / UPC-A / EAN-8 and Code 128 encoders (own code, ISO/IEC 15420 and 15417 tables).
Encoder\Qr QR Code encoder (ISO/IEC 18004): byte mode, versions 1-10, levels L/M/Q/H, Reed-Solomon, mask scoring.
Pdf\Writer Minimal PDF 1.4 writer: pages, filled rectangles, Helvetica / Helvetica-Bold (WinAnsi), Flate.
Renderer Draws labels onto the writer: sheet grids and rolls, text fitting, barcode sizing (whole 203 dpi dots).
Templates, Catalog, Prices, Printer, Numbers Database side: templates, products and codes (company scoped), price text, the print run, GS1 prefixes, number generation and the code scan.

Gtin, Symbology, Encoder\*, Pdf\Writer and Renderer do not call CS-Cart and run in plain PHP (the unit tests use them without a store).

  • ?:kv_bcl_templates: sheet and roll layouts. template_id 1-11 are the built-in rows (is_system = 'Y', re-seeded by the install query with INSERT IGNORE).
  • ?:kv_bcl_prefixes: GS1 company prefix and the next item number per company.
  • ?:kv_bcl_codes: own barcode numbers (source “own”).
  • ?:kv_bcl_log: the last 500 print runs per company.

kv_barcode_labels.print (GET with product_id, or POST with product_ids[], template_id, symbology, qty_mode, qty[<id>], price_source, currency, skip, dx, dy, outline, or scope=filter plus the filter fields) answers with application/pdf and the headers X-Kv-Bcl-Labels, X-Kv-Bcl-Skipped, X-Kv-Bcl-Pages and X-Kv-Bcl-Ms. When nothing can be printed it redirects back with a notice.

Barcodes are vector rectangles (no raster). Text uses the standard Helvetica fonts, so it is Latin-1 / Windows-1252: other characters are transliterated where possible and printed as ? otherwise. The barcode value itself is never altered, except that Code 128 supports printable ASCII only (other characters in a value become ?).

PHP hooks: delete_product_post, delete_company. Admin template hooks: products:update_tools_list and products:list_extra_links (post). The product list bulk actions are added through schemas/context_menu/products.post.php.

php tests/unit.php (no store): check digits, encoders against round-trip decoders, QR format information and Reed-Solomon vectors, PDF structure, renderer and the 1000-label budget. php tests/decode_test.php renders PDFs and reads them back with zxing-cpp (tests/decode_pdf.py; test tooling only). tests/e2e.mjs drives an installed store over HTTP (fixture: tests/e2e_fixture.php).