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/Services/Providers/Star_Online_Adapter.php +38 -0 1.10.13 → 1.10.21 View file →
@@ -7,8 +7,11 @@
7 7
8 8 namespace WCPOS\WooCommercePOS\Services\Providers;
9 9
10 10 use WCPOS\WooCommercePOS\Interfaces\Push_Provider_Adapter_Interface;
11 +use WCPOS\WooCommercePOS\Services\Print_Job_Service;
12 +use WCPOS\WooCommercePOS\Services\Cloud_Print_Trigger_Service;
13 +use WP_Error;
11 14 use WCPOS\WooCommercePOS\Services\Star_Online_Client;
12 15
13 16 /**
14 17 * Star_Online_Adapter class.
@@ -151,6 +154,41 @@
151 154 'error' => $error,
152 155 'external_job_id' => '',
153 156 'drawer_error' => '',
154 157 );
158 + }
159 +
160 + /**
161 + * Queue a Star Markup test receipt and submit it through the push pipeline.
162 + *
163 + * @param array $printer Registered star-online printer.
164 + *
165 + * @return \WP_REST_Response|WP_Error
166 + */
167 + public function test_print( array $printer ) {
168 + $jobs = new Print_Job_Service();
169 + $diag = $this->diagnostic( (string) $printer['name'] );
170 +
171 + $id = $jobs->create(
172 + array(
173 + 'printer_id' => $printer['id'],
174 + 'content_type' => 'text/vnd.star.markup',
175 + 'payload' => $diag['payload'],
176 + )
177 + );
178 + if ( $id <= 0 ) {
179 + return new WP_Error(
180 + 'wcpos_print_job_create_failed',
181 + __( 'Print job could not be created.', 'woocommerce-pos' ),
182 + array( 'status' => 500 )
183 + );
184 + }
185 +
186 + wp_schedule_single_event( time(), Cloud_Print_Trigger_Service::CRON_SUBMIT, array( $id ) );
187 + ( new \WCPOS\WooCommercePOS\Services\Cloud_Print_Submit_Service() )->submit( $id );
188 +
189 + $response = rest_ensure_response( $jobs->get( $id ) );
190 + $response->set_status( 201 );
191 +
192 + return $response;
155 193 }
156 194 }