Product Icon

Google for WooCommerce

Promote your products across Google - from Search to YouTube and beyond. So you can reach the right customers to make the most of your peak season.

Customized product titles

We would like to be able to customize the product title sent up to google.

The product titles on our website are shorter and more user-friendly. They’re optimized for someone browsing around our website who doesn’t know what they’re looking for.

On google we assume people know what they’re looking for. We want the product names to include more detail like the brand and manufacturer’s part number.

I got it to work the way I want by editing src/Product/WCProductAdapter.php in the Google for WooCommerce plugin. I added this function.

“`
protected function get_seo_title ( $product ) {
if ( $product instanceof WC_Product_Variation ) {
$parent_product = wc_get_product( $product->get_parent_id() );
$brand = $parent_product->get_attribute( ‘Brand’ );
$gids = $product->get_meta( ‘wpseo_variation_global_identifiers_values’, true );
if ( ! is_array( $gids ) || empty( array_filter( $gids ) ) ) {
$gids = $parent_product->get_meta( ‘wpseo_global_identifier_values’, true );
}
} else {
$brand = $product->get_attribute( ‘Brand’ );
$gids = $product->get_meta( ‘wpseo_global_identifier_values’, true );
}
$mpn = $gids[‘mpn’];
$space = $brand && $mpn ? ” ” : “”;
$extra = $brand || $mpn ? ” – ” . $brand . $space . $mpn : “”;
return $product->get_title() . $extra;
}
“`

and then changed the line that sets the product title to this.

“`
protected function map_wc_general_attributes() {
$this->setTitle( $this->get_seo_title( $this->wc_product ) );
“`

It would be great to have the capability in the plugin so I don’t have to edit the code each time we update.

Author

Ryan Boder

Current Status

Open

Last updated: November 8, 2024

0 comments

Log in to comment on this feature request.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.