Last active
May 16, 2017 05:30
-
-
Save SirDarcanos/506d631edf97202873aaf5fecbc138fc to your computer and use it in GitHub Desktop.
functions.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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