PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.21
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.21
1.10.25 1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 All 169 releases
← All changes | includes/Templates/Barcode_Symbology.php +51 -0 1.10.2 → 1.10.21 View file →
@@ -362,8 +362,59 @@
362 362 return $payload;
363 363 }
364 364
365 365 /**
366 + * Build the ePOS-Print XML payload for a barcode value.
367 + *
368 + * Code 128 uses the same `{B` selector and `{{` escaping as the ESC/POS
369 + * lane — the ePOS-Print spec defines the data identically. The branch is
370 + * keyed on the name ePOS will receive, not on normalize_linear(): that
371 + * folds every unmodelled type to Code 128, which would hand `{B` to the
372 + * pass-through symbologies in EPOS_XML_ONLY_TYPES (`jan13`, `gs1_128`,
373 + * `code128_auto`, …) and silently blank them.
374 + *
375 + * ePOS barcode data also has its own escape layer on top of the XML text:
376 + * `\xnn` is a control byte and `\\` a literal backslash (ePOS-Print XML
377 + * manual, <barcode> "escape sequences"). A raw backslash in a value would
378 + * therefore be decoded by the printer — `A\x41` scans as `AA` — so every
379 + * backslash is doubled first, for every symbology.
380 + *
381 + * Unlike escpos_payload() there is no MAX_DATA_BYTES clamp here: the
382 + * emitter validates the value up front with the ESC/POS rules and falls
383 + * back to text, and the data travels as XML rather than a length-prefixed
384 + * byte command, so a clamp could only ever produce a wrong-but-scannable
385 + * symbol.
386 + *
387 + * @param string $type The barcode type attribute value.
388 + * @param string $value The barcode value.
389 + *
390 + * @return string The XML barcode payload.
391 + */
392 + public static function epos_xml_payload( string $type, string $value ): string {
393 + $value = self::epos_xml_escape_data( $value );
394 +
395 + if ( self::DEFAULT_SYMBOLOGY === self::epos_xml_name( $type ) ) {
396 + return self::escpos_code128_data( $value );
397 + }
398 +
399 + return $value;
400 + }
401 +
402 + /**
403 + * Apply the ePOS-Print barcode/symbol data escape layer to a value.
404 + *
405 + * Shared by <barcode> and <symbol> (QR) data, which use the same
406 + * `\xnn` / `\\` escape sequences.
407 + *
408 + * @param string $value The raw value.
409 + *
410 + * @return string The value with literal backslashes doubled.
411 + */
412 + public static function epos_xml_escape_data( string $value ): string {
413 + return str_replace( '\\', '\\\\', $value );
414 + }
415 +
416 + /**
366 417 * Map a symbology to its StarPRNT `ESC b n1` selector.
367 418 *
368 419 * @param string $type The barcode type attribute value.
369 420 *