Skip to content

Instantly share code, notes, and snippets.

@mijankarim
Created December 2, 2018 12:48
Show Gist options
  • Save mijankarim/d2a8862052c027c28d6ef020126922b4 to your computer and use it in GitHub Desktop.
Save mijankarim/d2a8862052c027c28d6ef020126922b4 to your computer and use it in GitHub Desktop.
add_filter( 'woocommerce_cart_item_name', 'custom_variation_item_name', 10, 3 );
function custom_variation_item_name( $item_name, $cart_item, $cart_item_key ){
// Change item name only if is a product variation
if( $cart_item['data']->is_type('variation') ){
// HERE customize item name
$item = $cart_item['data'];
$item_name = $item->get_name();
// For cart page we add back the product link
if(is_cart())
$item_name = sprintf( '<a href="%s">%s</a>', esc_url( $cart_item['data']->get_permalink() ), $item_name );
}
return $item_name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment