Documentation

Append Trademark After The Product Title

You might want to dynamically add a Trademark symbol or something else after the product or variation title. If that’s the case, the below code snippet can be used to get it done:

/**
 * Append TM after the product title
 *
 * @param string $title
 * @param int $id
 *
 * @return string $title
 */
function iconic_update_post_title( string $title, int $id ): string {
	$allowed_post_ids = array( 1, 2, 3 );
	if ( in_array( $id, $allowed_post_ids ) ) {
		if ( 'product' === get_post_type( $id ) || 'product_variation' === get_post_type( $id ) ) {
			return $title . "TM";
		}
	}

	return $title;
}

add_filter('the_title', 'iconic_update_post_title', 10, 2);

WooCommerce Show Single Variations

Show WooCommerce variations as single products on the shop page, category pages, search results, and filtered results with WooCommerce Show Single Variations.

Was this helpful?

Please let us know if this article was useful. It is the best way to ensure our documentation is as helpful as possible.