• Resolved arthrnvrn

    (@arthrnvrn)


    Hi there,

    I’d like to add a product custom field in the product table, under each product if the custom field exists.

    Hooks I’ve tried not work for any reason.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @arthrnvrn,

    The easiest way to achieve it is using the {{product_custom_field::META_KEY}} placeholder, within the Product item column block in the customizer, included in Premium Templates:

    A screenshot that displayes the product custom field placeholder within a Product column

    However, if you have some PHP knowledge, you can take advantage of the PDF template action hooks and write a code snippet to achieve it.

    Here’s an example as reference:

    add_action( 'wpo_wcpdf_after_item_meta', function( $template_type, $item, $order ) {
    	if ( isset( $item['product'] ) && ! empty( $your_custom_field = $item['product']->get_meta( 'your_custom_field' ) ) ) {
    		echo '<div class="custom-field">Your Custom field: '.$your_custom_field.'</div>';
    	}
    }, 10, 3 );
    Thread Starter arthrnvrn

    (@arthrnvrn)

    Great, thank you @yordansoares !

    And, any idea how to make metas inline (sku/weight) ?

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Try adding this code snippet to your site to achieve it:

    /**
     * WooCommerce PDF Invoices & Packing Slips:
     * Makes SKU and Weight metadata inline
     */
    add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {	
    	if ( $document_type == 'invoice' ) {
    		?>
    		dt.sku, dt.weight, dd.sku, dd.weight {
    			display: inline-block;
    		}
    		dt.weight:before {
    			content: "|";
    			margin-right: 2pt;
    		}
    		<?php
    	}
    }, 10, 2 );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show up custom field’ is closed to new replies.