I am trying to add product ID as a suffix in the product title for example:
iPhoneX – 123 (where 123 is the ID)
The reason why I need this is something related to the payment gateway I am dealing with. hence, this solution only needs to be applied where it is necessary for the payment gateway to recognize that ID during checkout.
The following code shows product ID as a suffix on checkout the way I wanted. however, When placing the order and redirecting to the third-party payment gateway page; the ID does not show there. I want the third-party payment gateway to display it as well.
add_filter('the_title', 'change_woocommerce_single_title', 1, 2);
function change_woocommerce_single_title($title, $id) {
if ( class_exists( 'woocommerce' ) && is_checkout())
$title = $title . ' - ' . $id;
return $title;
}
2
Answers
You can create your own function to handle the product title. Put this code to
function.php
of your child theme:Try this: