Integration into Packing Lists and Invoices


You have two options to integrate stamp image files into packing slips and invoices: by using a shortcode or calling a function in a hook.

Important: In the settings the image data type PNG has to be selected to integrate image files into other documents.

Shortcode

The shortcode [mame_ws_stamp_image] can be used to display the stamps belonging to a WooCommerce order.

You can optionally pass three parameters to the shortcode:

  • width: the width of the image in px.
  • height: the height of the image in px.
  • newline: possible values: 0 , 1 (standard). The value1 will print each stamp on a new line if there are multiple stamps available for one order.

Example:

[mame_ws_stamp_image width=600 height=400 newline=0]

Some invoice and packing slip plugin don’t run the shortcode since the code is not executed in the post loop and therefore there is no post id. In this case please use the function  Webstamp_Order::print_stamp_images_from_woocommerce_order inside a hook function (see below).

Function call

By using the function Webstamp_Order::print_stamp_images_from_woocommerce_order you can display stamp images on the packing slip / invoice of an order.

The function expects the following parameters:

  • WC_Order $order: the WooCommerce order object.
  • int $width (optional): width of the image.
  • int $height (optional): height of the image.
  • bool $newline (optional): standard true. The value true will print each stamp on a new line if there are multiple stamps available for one order.

If you use the official WooThemes plugin WooCommerce Print Invoices & Packing Lists you could for example insert the following code into the functions.php file of your theme:

add_action( 'wc_pip_before_body', 'my_webstamp_display_stamps_function', 10, 4 ); 
function my_webstamp_display_stamps_function ($type, $action, $document, $order) {
        Webstamp_Order::print_stamp_images_from_woocommerce_order($order); 
}