• Hello,

    One of our clients would like to have a product’s SKU displayed in the search result. I know there isn’t a way to do it by default in the options, but how would I go about manually adding the SKU to the search result?

    Thanks in advance!

    David

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support crodriguez1991

    (@crodriguez1991)

    Hello David,

    Thanks for contacting us and I hope you’re doing well ??

    If you want to show the product sku in the product loop, maybe you can use the following code in the functions.php of your active theme

    if ( !function_exists('yith_product_sku_before_loop_item_title') ) {
    	function yith_product_sku_before_loop_item_title()
    	{
    		global $product;
    
    		if ($product) {
    			$sku = $product->get_sku();
    
    			if ($sku) {
    				$value = ' (#' . $sku . ')';
    				echo $value;
    			}
    		}
    	}
    
    	add_action('woocommerce_before_shop_loop_item_title', 'yith_product_sku_before_loop_item_title');
    }

    It will show the product sku in the product loop by default.

    Please, try it and let me know.

    Have a good day.

    Thread Starter davlab

    (@davlab)

    Hi Carlos!

    Thank you for the reply. The code you linked worked partially but not exactly for what I needed. However, I have talked to the programmer in charge of the project and it looks like there’s another plugin interfering with it so we will figure that out first.

    Thank you again for your time!

    David

    Plugin Support crodriguez1991

    (@crodriguez1991)

    Hello David,

    I hope you’re doing well ??

    I’m glad my code helped you.

    If you have any other questions related with our plugin, don’t hesitate to contact me, I’ll be happy to help you.

    Have a good day.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display SKU in search result’ is closed to new replies.