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