Skip to content

Instantly share code, notes, and snippets.

@kreamweb
Last active September 13, 2024 07:44
Show Gist options
  • Save kreamweb/e4211cda273c23bb1fc20d8d61f9809a to your computer and use it in GitHub Desktop.
Save kreamweb/e4211cda273c23bb1fc20d8d61f9809a to your computer and use it in GitHub Desktop.
** 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment