• Resolved bartlovepuch

    (@bartlovepuch)


    Is it possible to change the template in the packing slip so amount bigger than 1 get accented? 90% of our orders only have one per product so the onces that have more than one need to stand out, maybe with an underline

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

    (@yordansoares)

    Hi @bartlovepuch,

    This code snippet, that I just wrote for you, should do the trick:

    /**
     * PDF Invoices & Packing Slips for WooCommerce:
     * Highlight the product quantity on the packing slip if it's higher than 2
     */
    add_filter( 'wpo_wcpdf_order_items_data', function( $data_list, $order, $document_type ) {
      if ( $document_type = 'packing-slip' ) {    
        foreach ( $data_list as $item_id => $item ) {
          if ( $item = $item['item'] ) {
            if ( $item->get_quantity() > 1 ) {
              $data_list[$item_id]['quantity'] = sprintf( '<span style="color:red"><strong>%s</strong></span>',  $item->get_quantity() );
            }
          }
        }
      }
      return $data_list;
    }, 10, 3 );

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

    Thread Starter bartlovepuch

    (@bartlovepuch)

    Thanks! That seems to work,

    we tweaked the code a bit to also add an underscore since we print in black/white but perfect for the rest!

    /**
     * PDF Invoices & Packing Slips for WooCommerce:
     * Highlight the product quantity on the packing slip if it's higher than 2
     */
    add_filter( 'wpo_wcpdf_order_items_data', function( $data_list, $order, $document_type ) {
      if ( $document_type = 'packing-slip' ) {    
        foreach ( $data_list as $item_id => $item ) {
          if ( $item = $item['item'] ) {
            if ( $item->get_quantity() > 1 ) {
              $data_list[$item_id]['quantity'] = sprintf( '<span style="font-size: 17pt; text-decoration: underline;"><strong>%s</strong></span>',  $item->get_quantity() );
            }
          }
        }
      }
      return $data_list;
    }, 10, 3 );
    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for sharing your code snippet version, @bartlovepuch! It may be useful for other users ??

    If you don’t mind and have the time, do you think you could leave us a review?

    Thanks in advance and all the best with your store!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Mark amounts if bigger than 1’ is closed to new replies.