Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save BillKarkavos/c93b9b5c070b6422da7dc99e183bb1ce to your computer and use it in GitHub Desktop.

Select an option

Save BillKarkavos/c93b9b5c070b6422da7dc99e183bb1ce to your computer and use it in GitHub Desktop.
Removes the attribute from the product title, in the cart - WC3
/**
* Removes the attribute from the product title, in the cart.
*/
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 );
add_filter( 'woocommerce_is_attribute_in_product_name', '__return_false' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment