PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.16
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.16
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 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 1.9.13 All 162 releases
woocommerce-pos / includes / Templates / Adapters / Html_Output_Adapter.php

Html_Output_Adapter.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.16, at includes/Templates/Adapters/Html_Output_Adapter.php

41 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * HTML output adapter.
4 *
5 * @package WCPOS\WooCommercePOS\Templates\Adapters
6 */
7
8 namespace WCPOS\WooCommercePOS\Templates\Adapters;
9
10 use WCPOS\WooCommercePOS\Interfaces\Receipt_Output_Adapter_Interface;
11
12 /**
13 * Html_Output_Adapter class.
14 */
15 class Html_Output_Adapter implements Receipt_Output_Adapter_Interface {
16 /**
17 * Transform receipt payload to HTML representation.
18 *
19 * @param array $receipt_data Canonical payload.
20 * @param array $context Optional context.
21 *
22 * @return string
23 */
24 public function transform( array $receipt_data, array $context = array() ): string {
25 if ( isset( $context['html'] ) && \is_string( $context['html'] ) ) {
26 return wp_kses_post( $context['html'] );
27 }
28
29 $order_number = isset( $receipt_data['order']['number'] ) ? (string) $receipt_data['order']['number'] : '';
30 $total = isset( $receipt_data['totals']['total_incl'] ) ? (float) $receipt_data['totals']['total_incl'] : 0;
31
32 return sprintf(
33 '<div class="wcpos-receipt" data-order="%s"><strong>%s</strong>: %s</div>',
34 esc_attr( $order_number ),
35 /* translators: Short WCPOS UI label; keep concise. */
36 esc_html__( 'Order', 'woocommerce-pos' ),
37 wp_kses_post( wc_price( $total ) )
38 );
39 }
40 }
41