Last active
September 13, 2024 07:44
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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