You are currently viewing How To Send WooCommerce Orders & Invoices By Fax in 2018

How To Send WooCommerce Orders & Invoices By Fax in 2018

Recently, one of our ecommerce clients requested that WooCommerce orders be sent to their analog fax machine. It made sense for them, a busy restaurant who wants to pick up orders off of the fax as they come in real-time. Searching Google we found one seemingly broken plugin and one reddit post suggesting the solution of signing up for a virtual fax machine (think TrustFax or eFax) and then forwarding to the clients physical fax line. 

Nextiva's $150 faxbridge, annual pricing & omg that layout!

We quickly ran into some issues going the email-to-fax method. We found Nextiva to be one of the cheapest options for virtual faxes, but after signing up, it was discovered that you’d need to purchase a $150.00 Fax Bridge device in order for your physical fax machine to receive ones sent to your virtual fax machine. (What?!) As for TrustFax and other “eFaxes”, we found that you’d need to spend around $120 to qualify for the $10.89/mo package, allowing for 500 faxes per month (ouch). 

When we did get this method to finally work via TrustFax, we noticed that the resulting fax didn’t look anything like the email. To put it simply, it looked awful.


After some additional searching we found that Twillio is the least expensive option. Loading your account with $20 will allow you to send about 1,000 faxes and credits don’t expire month-to-month. 

To start, signup for a Twilio account and download the Twillio PHP Helper library to your theme’s main folder (i.e. /var/www/html/ Then, modify your functions.php file and add the following 2 lines after <?php 

require __DIR__ . ‘/twilio-php-master/Twilio/autoload.php’;

use Twilio\Rest\Client;

Now, download the WooCommerce PDF Invoice Packaging Slips plugin and install it to your wordpress. After it’s installed, add the following hook in your theme’s functions.php replacing information in red with your own.

add_action(‘woocommerce_thankyou’, ‘fax_woocommerce_order’, 10, 1);

function fax_woocommerce_order( $order_id ) {

    if ( ! $order_id )


        // Twilio account credentials

        $sid = AC282xxxxxxxxxxxxxxxxxx;

        $token = cdd57xxxxxxxxxxxxxxxxxxxx;

        $twilio = new Client($sid, $token);

        // Getting an instance of the order object

        $order = wc_get_order( $order_id );

        // Get invoice from ‘WooCommerce PDF Invoice Packaging Slips’ plugin

        $invoice = wcpdf_get_invoice($order);

        $pdf_data = $invoice->get_pdf();

        $filename = $invoice->get_filename();

        $upload_dir = wp_upload_dir();

        $pdf_path = $upload_dir[‘basedir’] . ‘/wpo_wcpdf/attachments/’ .$filename;

        file_put_contents ( $pdf_path, $pdf_data );

        $pdf_file =$filename;

        $fax = $twilio->fax->v1->faxes->create(+1814XXXXXXX,$pdf_file,array(‘from’ => +1720XXXXXX));


$sid – Get your account ID on Twilio’s dashboard
$token – Get your account token in the same place
$pdf_file – Replace with your website so Twilio can access your order PDF via this url
$fax – first phone number is the number to send to and the second number is your twilio verified phone number.

Take note that the hook is placed on the thank you page. You can change this to after payment confirmation or add any other type of conditional logic in your hook before sending the fax. Here is a fax received via this method.

Keystone Web Studios

A Pennsylvania based IT consulting firm specializing in Wordpress & custom framework website / application development, ecommerce platforms, native mobile application development, SEO/SEM services, digital marketing management & technical support. Call us anytime! 855-942-0303

Leave a Reply