• Resolved Thane

    (@thanewest)


    Hey Ewout,
    I have some Variable products and wondering if there is an easy way to separate the variation name from the product title – for example I have a product that shows on the pdf like this:
    Product Name – Variation/Attrib Name
    And i’d like to get it to look like this:
    Product Name – <b>Variation/Attrib Name</b>
    Or:
    Product Name
    Variation/Attrib Name

    I don’t think there’s something in the template for me to do this, any ideas?

    My premo extension is version 2.3.1 too, so I’ll be upgrading that sometime this week – cross my fingers it doesn’t break anything lol ??

    Thanks pal!

    • This topic was modified 6 years, 10 months ago by Thane.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi!
    The variation attributes in the product titles is a ‘feature’ that was introduced in WooCommerce 3.0…

    You can remove the attributes from the title with the following code snippet:

    
    add_filter( 'woocommerce_product_variation_title_include_attributes', '__return_false' );
    

    However, I believe this will only affect new orders and you’d still need to add the variation name to the meta.

    You could also use the woocommerce_product_variation_title filter, but reformatting the title as per your first option is probably the easiest option here.

    
    add_filter( 'wpo_wcpdf_order_item_data', 'wpo_wcpdf_order_item_name', 10, 3 );
    function wpo_wcpdf_order_item_name( $item, $order, $document_type ) {
    	if ( strpos($item['name'], ' - ') !== false ) {
    		$name_parts = explode(' - ', $item['name']);
    		$last = count($name_parts)-1;
    		$name_parts[$last] = "<b>".$name_parts[$last]."</b>";
    		$item['name'] = implode(' - ', $name_parts);
    	}
    	return $item;
    }
    

    Hope that helps!
    Ewout

    Thread Starter Thane

    (@thanewest)

    Thanks Ewout, a little modification to the last script to suit my site worked like a charm!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Edit Variation Attributes In Titles’ is closed to new replies.