• Resolved IZALK

    (@izalk)


    Hi,

    Great plugin, been using it for a while now, works great.

    My question:
    In my emails I recently added the total amount of items that are in the order..
    IE.
    2 Shirts
    3 Sweaters

    Total items: 5.

    I do this by adding:
    <?php echo $order->get_item_count() ?>

    I tried to add this to the PDF as well, didn’t work. Tried a number of variations such as:
    <?php echo $wpo_wcpdf->get_item_count() ?>

    But I always get the error “Call to a member function get_item_count() on a non-object”..

    Any suggestions as to how to solve this?

    Thanks in advance.

    https://www.ads-software.com/plugins/woocommerce-pdf-invoices-packing-slips/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter IZALK

    (@izalk)

    Okay, managed to get this working by doing the following,

    adding an extra function to your plugin:

    /**
    * Return/Show the order total amount
    */
    public function get_total_items() {
      $total_items = $this->export->order->get_item_count();
      return $total_items;
    }
    
    public function total_items() {
      echo $this->get_total_items();
    }

    then adding this to my PDF template:

    <?php $totalitems = $wpo_wcpdf->get_total_items(); ?>
    <?php _e( "Total Items:", 'woocommerce' ); ?><strong> <?php echo $totalitems ?></strong>

    Maybe you could help me move that function to my functions.php instead of the plugin file, so it won’t get overwritten when updating the plugin?

    Thanks in advance, and I hope this is helpfull to somebody else as well ??

    Plugin Contributor Ewout

    (@pomegranate)

    Hello IZALK,
    It’s not neccessary to create a function for this purpose!
    you can just put this in the template:

    <?php _e( "Total Items:", 'woocommerce' ); ?><strong> <?php echo $wpo_wcpdf->export->order->get_item_count() ?></strong>

    Thread Starter IZALK

    (@izalk)

    Awesome, thank you.
    Can’t believe that out of the 20+ combo’s I tried I didn’t try that one ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display total amount of items on PDF’ is closed to new replies.