• Resolved Kitty

    (@k1t)


    Hi there, not sure if any of this is possible with the free version/support or if I need to upgrade?

    I’m looking to add the following product data to a custom packing slip template:
    – Brand (taxonomy term)
    – Product thumbnail
    – Remaining stock quantity of product

    Any help or advice is much appreciated. Thank you!

Viewing 1 replies (of 1 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! You can add product thumbnails and remaining stock with the Premium Templates extension. We don’t have built in support for brand taxonomy in either the free version or paid extension, but you can add this with a bit of custom code. If you use WC Brands, here’s how you can add it:

    
    add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_show_product_brands', 10, 3 );
    function wpo_wcpdf_show_product_brands ( $template_type, $item, $order ) {
        if (isset($item['product'])) {
            if ( $item['product']->is_type( 'variation' ) ) {
                $product_id = method_exists( $item['product'], 'get_parent_id' ) ? $item['product']->get_parent_id() : wp_get_post_parent_id( $item['product']->get_id() );
            } else {
                $product_id = $item['product']->get_id();
            }
    
            $brand_count = sizeof( get_the_terms( $product_id, 'product_brand' ) );
    
            $taxonomy = get_taxonomy( 'product_brand' );
            $labels   = $taxonomy->labels;
    
            echo '<div class="brands">';
            echo get_brands( $product_id, ', ', ' <span class="posted_in">' . sprintf( _n( '%1$s: ', '%2$s: ', $brand_count ), $labels->singular_name, $labels->name ), '</span>' );
            echo '</div>';
        }
    }
    

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

    If you have any further question about the paid extensions, please send an email to support@wpovernight.com and we’ll do our best to help!

Viewing 1 replies (of 1 total)
  • The topic ‘Adding custom product info’ is closed to new replies.