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

    (@yordansoares)

    Hi @greentktx,

    This is indeed possible, although we do not offer this page size by default, since our default Simple template is not prepared for small layouts, but you can always set your own customizations by your own. See: Use custom page size/orientation & Using custom styles.

    That said, I have written two code snippets, as a courtesy for you, so you can achieve this faster and effortless.

    The first, set the packing slip page/paper size to 4×6 inches:

    /**
     * PDF Invoices & Packing Slip for WooCommerce:
     * Set the paper size to 4x6 inches
     */
    add_filter( 'wpo_wcpdf_paper_format', function( $paper_format, $document_type ) {
    	if ( $document_type == 'packing-slip' ) {
    		// change the values below
    		$width = 4; //inches!
    		$height = 6; //inches!
    	 
    		//convert inches to points
    		$paper_format = array( 0, 0, $width * 72, $height * 72 );
    	}
        return $paper_format;
    }, 10, 2 );

    The second, adds some CSS rules to customize the packing slip styles*, in order to adapt our default layout to this small page/paper size:

    /**
     * PDF Invoices & Packing Slip for WooCommerce:
     * Add custom styles to the PDF documents 
     */
    add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {
    	if ( $document_type == 'packing-slip' ) {
        ?>
    	/*Reduce page margins*/
    	@page {
    		margin-top: .5cm;
    		margin-bottom: .5cm;
    		margin-left: .5cm;
    		margin-right: .5cm;
    	}
    	/* Document label */
    	h1 {
    		font-size: 8pt;
    	}
    	/* Shop name and other labels */
    	h3, h4 {
    		font-size: 7pt;
    	}
    	/* Document body and order table  */
    	body {
    		font-size: 7pt;
    	}
    	dt, dd, dd p, .wc-item-meta {
    		font-size: 6pt;
    	}
        <?php
    	}
    }, 10, 2 );

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

    Let me know whether you managed to make it work or you need more help!

    * FYI: There is another way to achieve the same, creating a custom PDF template, but please note that we do not provide assistance for it for free. Even if you have a license for either Professional extension or Premium Templates, we only offer help for this as a custom job for an extra fee, since this is an advanced customization which involves more time and work (and I believe it is not necessary for your particular case ;)).

    Thread Starter greentktx

    (@greentktx)

    It looks like the function worked but the CSS is not working

    https://imageupload.io/FCA8krNc0b5F05a

    • This reply was modified 1 year, 1 month ago by greentktx.
    • This reply was modified 1 year, 1 month ago by greentktx.
    Plugin Contributor Yordan Soares

    (@yordansoares)

    Although the second code snippets inject some CSS classes, it is wrapped into a PHP code, therefore, you have to activate it in the PHP tab.

    Plugin Contributor dwpriv

    (@dwpriv)

    @greentktx

    You’re adding the second code as a CSS snippet. It should still be added as a PHP snippet like the first code.

    Thread Starter greentktx

    (@greentktx)

    thank you. that did the trick

    Plugin Contributor dwpriv

    (@dwpriv)

    @greentktx

    Great. We will mark this as resolved then

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Can we get a 4×6 paper option for packing slips?’ is closed to new replies.