Created
March 20, 2018 11:07
-
-
Save BillKarkavos/c93b9b5c070b6422da7dc99e183bb1ce to your computer and use it in GitHub Desktop.
Removes the attribute from the product title, in the cart - WC3
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. | |
| */ | |
| 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