Skip to content

Instantly share code, notes, and snippets.

@SiR-DanieL
Last active May 16, 2017 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiR-DanieL/506d631edf97202873aaf5fecbc138fc to your computer and use it in GitHub Desktop.
Save SiR-DanieL/506d631edf97202873aaf5fecbc138fc to your computer and use it in GitHub Desktop.
functions.php
/**
* Removes the attribute from the product title, in the cart.
*
* @return string
*/
function remove_variation_from_product_title( $title, $cart_item, $cart_item_key ) {
$_product = $cart_item['data'];
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
if ( $_product->is_type( 'variation' ) ) {
if ( ! $product_permalink ) {
return $_product->get_title();
} else {
return sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_title() );
}
}
return $title;
}
add_filter( 'woocommerce_cart_item_name', 'remove_variation_from_product_title', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment