Hide parts of woocommerce product title

October 14, 2023 01:11:53
eliodata
Topics: 19
Messages: 57
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
October 14, 2023 03:39:38
E2Pdf
Topics: 7
Messages: 3617
Support
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!
October 14, 2023 03:47:26
eliodata
Topics: 19
Messages: 57
Thank you for the quick support, as usual!
Sorry but it doesn't work.
October 14, 2023 03:49:45
E2Pdf
Topics: 7
Messages: 3617
Support
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!
October 14, 2023 04:33:27
eliodata
Topics: 19
Messages: 57
You are right. I had the option "disable WYSIWYG Editor" unchecked, so some characters went wrong after copy paste your code.
Many thanks!!!
Get News and Updates
Our monthly newsletter keeps you in the loop, so you'll always be up to date with the latest news and updates about E2Pdf.
* You can update your email subscription preferences here.
All trademarks, service marks, trade names, product names, and logos appearing on this website are the property of their respective owners. The use of trademarks such as Formidable Forms®, Forminator Forms®, Gravity Forms®, JetFormBuilder®, WordPress®, WooCommerce®, WPForms® and others is solely for identification purposes (nominative use) and does not imply any affiliation, sponsorship, or endorsement by the respective trademark holders.
© 2017 - 2026, https://e2pdf.com

We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements. By clicking "Accept Selected", you consent to use of selected cookies according to our Cookie Policy.