sanitize_zpl_text( $store_name ) . '^FS', '^FO30,65^FDWCPOS RECEIPT^FS', '^FO30,75^FDOrder #' . $order_number . '^FS', '^FO30,120^FDTotal ' . wc_format_decimal( $total, wc_get_price_decimals() ) . '^FS', ); if ( $print_barcode ) { $zpl[] = '^BY2,2,60'; $zpl[] = '^FO30,170^BCN,60,Y,N,N'; $zpl[] = '^FD' . $this->sanitize_zpl_text( $order_number ) . '^FS'; } if ( $print_qr && '' !== $qr_payload ) { $zpl[] = '^FO30,260^BQN,2,6'; $zpl[] = '^FDLA,' . $this->sanitize_zpl_text( $qr_payload ) . '^FS'; } $zpl[] = '^XZ'; return implode( "\n", $zpl ); } /** * Sanitize text for ZPL fields. * * @param string $value Text value. * * @return string */ private function sanitize_zpl_text( string $value ): string { $value = preg_replace( '/[\^~]/', '-', $value ); return trim( $value ); } }