Integration & Printer Setup


We go over the basics and show you the necessary steps needed after signing up. We’ll explore other areas from sending a test order (to ensure everything is in working order), to setting up our plugin extensions.

Use the table of contents below to select your topic of interest.

How to build an order status page for customers

WordPress WooCommerce integration with PrinterCo - Tablet POS printers

In this tutorial, we’ll show you how you can get the Order ID, Order Status and the time the order was Accepted For, so that you can notify your customers soon after the kitchen processes the request.

You probably had to create a Notify URL page when setting up our plugin for WooCommerce.  The shortcode in this page triggers a function that retrieves certain data for the most recent order, one of which is the Order Status. The function then saves this data into the database of your website.

So, what we will be doing is accessing this database, and then check every 20 seconds to see if the order status has been updated from Pending to either Accepted or Rejected. This code will be placed in the WooCommerce thankyou.php page so the customer can see the updates immediately after placing an order.

Purpose of the Notify URL

Let's Get Started!

 Step 1 – Install the “INSERT PHP CODE SNIPPET” plugin
  1. Download the free version. Upload, install and activate it for your WordPress site.
 Step 2 – Create The Shortcode
  1. From the WordPress panel on the left, scroll down to XYZ PHP Code > PHPCode Snippets.
  2. Click the Add New PHP Code Snippet button.
 Step 3 – Copy & Paste Code
  1. Enter a name for your shortcode.
  2. Copy and paste the code snippet below into the PHP code field.
//Query for get latest orders
$query = new WC_Order_Query( array
    	'limit' => 1,
    	'orderby' => 'date',
    	'order' => 'DESC',
    	'return' => 'ids',
$orders = $query->get_orders();
//End query

//Loop to display orders for multiple users at a time
foreach($orders as $order)
  $unix_timestamp = get_post_meta( $order, '_iconnect_notification_agreed_time', true );
  $datetime = new DateTime("@$unix_timestamp");
  $gmtdate = $datetime->format('d-m-Y H:i:s'); //converts time to GMT

<!–– Code to get status code ::: 0 = waiting for responce :: 1 = accepted :: 2 = rejected -->

<?php $order_status = get_post_meta( $order, '_iconnect_notification_status', true );?>
<?php if ( $order_status == 0 ) : ?>

<script type="text/javascript">
    window.onload = setupRefresh;
    function setupRefresh() 
    setTimeout("refreshPage();", 20000); // milliseconds
    function refreshPage() 
       	window.location = location.href;

<center><img src="" width="60%" /></center>
<?php endif; ?>

<?php if ( $order_status == 1 ) : ?>
    //Order Accepted Status Bar Image
    <img src="" width="60%" />
    <div style="font-size:20px;font-weight:700;margin-top:20px;">
      Order Accepted for: <?php echo $gmtdate; ?>
<?php endif; ?>

<?php if ( $order_status == 2 ) : ?>
    //Order Rejected Status Bar Image
    <img src="" width="60%" />
<?php endif; ?>

  display:none !important;
 Step 4 – Paste Your Shortcode Into The WooCommerce ThankYou.php page
1. After you click the Create button, you will see your shortcode. Copy this to your clipboard to use it later.
2. Using an FTP client (like FileZilla), connect to your WordPress website and navigate to wp-content > plugins > woocommerce > templates > checkout > thankyou.php

3. Paste the following code just after line 41 where the code reads … <p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); ?></p>

Insert this code:

Note: Replace “Live-Order-Status” with the name of your shortcode, if you decided to change it to something else.

<div id="status"></div>
<center><h3>Status from restaurant</h3></center>
<?php echo do_shortcode('[xyz-ips snippet=Live-Order-Status]');?>
And that’s it! Send a test order and you should see the same results as shown below…

Leave a comment

Enter your keyword