kreamweb
2/21/2020 - 10:20 AM

[POS] Add Sku inside search results

** YITH Point of Sale for WooCommerce**

How add the Sku inside search results

<?php

add_filter( 'woocommerce_rest_prepare_product_object', 'yith_pos_custom_product_response', 20, 3 );

function yith_pos_custom_product_response( $response, $object, $request ) {
	$param = $request->get_param( 'queryName' );
	if ( $param == 'yith_pos_search' ) {
		$result         = $response->data;
		$result['name'] .= empty($result['sku']) ? '' : ' - ' . $result['sku'];
		$response->data = $result;
	}

	return $response;
}