Skip to content

Instantly share code, notes, and snippets.

@plugin-republic
Created August 25, 2025 10:46
Show Gist options
  • Save plugin-republic/8997cd4294b9851861e0c4c974baa616 to your computer and use it in GitHub Desktop.
Save plugin-republic/8997cd4294b9851861e0c4c974baa616 to your computer and use it in GitHub Desktop.
<?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