Created
August 25, 2025 10:46
-
-
Save plugin-republic/8997cd4294b9851861e0c4c974baa616 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Remove attributes from product names of variation child products | |
*/ | |
function demo_filter_child_product_title( $title, $child_product ) { | |
if( ! is_object( $child_product ) || is_wp_error( $child_product ) ) { | |
return $title; | |
} | |
if( $child_product->get_type() == 'variation' ) { | |
$parent_id = $child_product->get_parent_id(); | |
$parent_product = wc_get_product( $parent_id ); | |
$title = $parent_product->get_name(); | |
} | |
return $title; | |
} | |
add_filter( 'pewc_child_product_title', 'demo_filter_child_product_title', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment