PDF Stamper improvements

Not only are we actively maintaining all our plugins, but we have been trickling out improvements… realized while we work on the successor to our PDF stamping plugins. For example, with version 1.2 of PDF Stamper (and v1.3 of EDDiStamper) there is better handling of PDF pages of varying size, in order to keep stamps inside the page boundaries, where you want them. These improvements occur as parent library improvements occur, and as we learn and grow!

Oftentimes people wish to create their own dynamic shortcodes for stamping customer/user data on PDF files. We’ve made that easier with the filter hook ‘woostamper_filter_shortcodes.’ This hook allows you to adjust how stamping shortcodes (such as [FIRSTNAME], [EMAIL] etc) are parsed. Here is some example code showing how this filter might be used to prefer the WordPress user profile data over WooCommerce order data (with order data as a fallback):

 * Filter the shortcode array to use other values for native shortcodes
 * @param array $shortcodes
 * @return array
function my_pdfstamper_filter_shortcodes( $shortcodes ) {

    // PDF Stamper uses WooCommerce order information by default
    // if a WP user is logged in, let's try using their WP profile information instead
    // if none exists, fall back to order information provided in $shortcodes parameter array
    if ( is_user_logged_in() ) {
        $user                       = wp_get_current_user();
        $shortcodes['[FIRSTNAME]']  = empty( $user->user_firstname ) ? $shortcodes['[FIRSTNAME]'] : $user->user_firstname;
        $shortcodes['[LASTNAME]']   = empty( $user->user_lastname ) ? $shortcodes['[LASTNAME]'] : $user->user_lastname;
	$shortcodes['[EMAIL]']      = empty( $user->user_email ) ? $shortcodes['[EMAIL]'] : $user->user_email;

    return $shortcodes;

add_filter( 'woostamper_filter_shortcodes', 'my_pdfstamper_filter_shortcodes', 10, 1 );

A developer will see how this filter could easily be used to create a custom shortcode to bring in other data from the user profile, order object, or even something custom from the database associated with the user or order ID.

EDDiStamper has also been updated, with a filter called ‘eddistamper_filter_shortcodes’ which will work similarly to the PDF Stamper filter. EDDiStamper has limited built-in shortcodes because default Easy Digital Download transactions don’t gather much customer detail. So this filter allows the user to dive in and get stamping details out of the data you know you have!