Support » Plugin: WooCommerce PDF Invoices & Packing Slips » Add SKU to product line to save space

  • Resolved vitalseeds


    HI – great plug-in – really simple and effective.

    I would like to know if there is a snippet i can use to move the SKU onto the same line as the product? This would save us a lot of paper! Also if there was a way to get rid of the ‘SKU’ text and just have the SKU that would be great. Example below.
    French Marigold – Orange (Organic)
    SKU: XFM
    XFM – French Marigold – Orange (Organic)



    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Ewout


    This is possible, although not super simple… You can prefix the name with the SKU with a small code snippet:

    add_filter( 'wpo_wcpdf_order_item_data', 'wpo_wcpdf_sku_in_name', 10, 3 );
    function wpo_wcpdf_sku_in_name ( $item, $order, $template_type ) {
    	if (!empty($item['sku'])) {
    		$item['name'] = "{$item['sku']} - {$item['name']}";
    	return $item;

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    You can then hide the separate SKU with CSS (documentation here):

    .sku { display: none; };

    Thanks for your reply – the filter worked well.

    With the CSS can i put <.sku { display: none; };> straight into the functions.php file or do i need to add a different code if doing it that way? Or can i add it to the snippet above?

    Plugin Author Ewout


    No you need a separate function for that, it’s all in that documentation link from my post: Using custom styles

    Ah ok – is this what i would add to my functions.php?

    add_action( ‘wpo_wcpdf_custom_styles’, ‘wpo_wcpdf_custom_styles’, 10, 2 );
    function wpo_wcpdf_custom_styles ( $document_type, $document ) {
    .sku { display: none; };

    Plugin Author Ewout


    correct, although I did make a small typo! That last ; should be omitted:

    .sku { display: none; }

    Thats brilliant thanks so much – worked perfectly! I have one more question but ill write in new thread as its unrelated

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.