How do I get a barcode in Magento email template
I found this out while scouring the net on my quest for all my other recent problems.
Zend has a built in barcode generation class, Zend_Barcode. Then googling php image output, I put together this little script I uploaded to var/export/_barcode.php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <?php require_once '../../app/Mage.php' ; umask(0); Mage::app(); Mage::app()->loadArea(Mage_Core_Model_App_Area::AREA_FRONTEND); if ( isset( $_GET [ 'ord' ]) && strlen ( $_GET [ 'ord' ]) > 5 ) { header( 'Content-Type: image/jpeg' ); $barcodeOptions = array ( 'text' => $_GET [ 'ord' ]); $rendererOptions = array (); // Draw the barcode in a new image, $imageResource = Zend_Barcode::draw( 'code39' , 'image' , $barcodeOptions , $rendererOptions ); imagejpeg( $imageResource ); } else { echo "<pre><b>Error:</b> required input not found\n" ; } ?> |
If you visit this script’s URL with the standard GET, you’ll be served a scannable barcode. So put this in your Transactional Email template:
1 2 3 4 | alt = "{{var order.increment_id}}" style = "margin-bottom:10px;" border = "0" /> |