• Resolved Grid24

    (@grid24)


    I love your plug-in but I am really struggling to get the invoice to show the product description. I have read over and over your tutorial on how to add either a theme hook or create a custom template. But neither way works for me.

    I woud prefer to add the code in your documentation to the theme functions file:

    add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_show_product_full_description', 10, 3 );
    function wpo_wcpdf_show_product_full_description ( $template_type, $item, $order ) {
        if (empty($item['product'])) return;
     
        $_product = wc_get_product( $item['product']->get_parent_id() );
        $description = $_product->get_description();
     
        printf('<div class="product-description">%s</div>', $description );
    }

    But, when I do this, I get a fatal error:

    Fatal error: Call to a member function get_short_description() on boolean
    

    Please can you help!

    If you can supply a template as your ‘Simple’ basic template, but with the description already added, that would be helpful as well.

    Many thanks.

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

    (@alexmigf)

    Hello @grid24

    Sorry, was a bug in the documentation, already fixed.

    This should work:

    add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_show_product_full_description', 10, 3 );
    function wpo_wcpdf_show_product_full_description ( $template_type, $item, $order ) {
        if (empty($item['product'])) return;
        if ( method_exists( $item['product'], 'get_description' ) ) {
            $_product = $item['product']->is_type( 'variation' ) ? wc_get_product( $item['product']->get_parent_id() ) : $item['product'];
            $description = $_product->get_description();
        }
     
        printf('<div class="product-description">%s</div>', $description );
    }
    Thread Starter Grid24

    (@grid24)

    Yay! Fantastic. It works.

    Thank you so much for such a quick reply.

    Happy to review/recommend your awesome plug-in to anyone.

    Stay safe and stay well.

    Plugin Contributor alexmigf

    (@alexmigf)

    Glad it worked ??

    We will be very happy if could drop us a review.

    Have a great day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can’t display product description’ is closed to new replies.