Hide parts of woocommerce product title

14 October, 2023 01:11:53
eliodata
Topics: 16
Messages: 49
Hi,

We use e2pdf to generate many documents from woocommerce.
All my products titles have the same format:
product name > date and place
For some reasons I only display the product name part of the title in front end, with this snippet:

add_filter( 'the_title', 'masquer_partie_titre_produit', 10, 2 );
function masquer_partie_titre_produit( $title, $id = null ) {
if ( (is_product() || is_product_category() || is_shop()) && in_the_loop() && get_post_type( $id ) === 'product' ) {
$parts = explode( '>', $title );
if ( count( $parts ) > 1 ) {
return trim($parts[0]);
}
}
return $title;
}

I would like e2pdf to have the same behaviour. I have tried some code but no result...

Can you help me to do this or give some clues please?

Best regards
14 October, 2023 03:39:38
E2Pdf
Support
Topics: 7
Messages: 3335
Hello,

Can you try to use the construction as follows inside the E2Pdf Template:

[e2pdf-format-output filter="explode,trim" explode=">" output="{0}"][e2pdf-wc-product key="get_name"][/e2pdf-format-output]

[e2pdf-wc-product key="get_name"] must be replaced with your shortcode that outputs the product title.
We would really appreciate your feedback at WordPress.org!
14 October, 2023 03:47:26
eliodata
Topics: 16
Messages: 49
Thank you for the quick support, as usual!
Sorry but it doesn't work.
14 October, 2023 03:49:45
E2Pdf
Support
Topics: 7
Messages: 3335
We did check on our side and it actually must work.

Does it output a full title?

Can you please attach the screenshot of the "Value" in properties? so we can see the setup? and a result PDF?
We would really appreciate your feedback at WordPress.org!
14 October, 2023 04:33:27
eliodata
Topics: 16
Messages: 49
You are right. I had the option "disable WYSIWYG Editor" unchecked, so some characters went wrong after copy paste your code.
Many thanks!!!