I am showing SKU value with product title in cart page but right now each words SKU and product title getting linking separately.how can i show just single link rather then having linking separately.
for showing SKU value In cart page added this code in Functions.php
add_filter( 'woocommerce_cart_item_name', 'add_sku_in_cart', 20, 3);
function add_sku_in_cart( $title, $values, $cart_item_key ) {
$sku = $values['data']->get_sku();
$url = $values['data']->get_permalink( $product->ID );
$final='<a href="'. $url .'">SKU: '. $sku .'</a>';
return $title ? sprintf("%s - ", $final) .$title : $final;
}
Example Right now showing this
<a href="http://localhost/test/?product=child-product">SKU: asda121 </a> - <a href="http://localhost/test/?product=child-product">Child Product</a>
but I want it like that
<a href="http://localhost/test/?product=child-product">SKU: asda121 - Child Product</a>