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

Connect your GloriaFood store to an order printer

GloriaFood integration with PrinterCo - Tablet POS printers
In this tutorial, we’ll go through the necessary steps to connect your GloriaFood website to the PrinterCo order printer. This will enable you to print orders that have been approved from the Gloriafood app straight to GloriaFood order printer.
 
Save time and workspace with our GloriaFood order printer. Accept and print your GloriaFood online orders from a single device. Download the GloriaFood Android app right onto our order printer. Our printer will print online orders while running in the background. This saves you time from having to switch between the GloriaFood app.
Prerequisites: 
For this tutorial, you need access to a website hosting account. You’ll be required to upload a PHP file to a server for GloriaFood to connect to. This is, in essence, the file to integrate both systems (GloriaFood & PrinterCo) together.

Let's Get Started!

 Step 1 – Login to your GloriaFood dashboard
  1. Head over to www.gloriafood.com and log into your dashboard.
  2. You should see a list of your restaurants. If this is not the case, click the Management link under the Restaurants, found in the left-hand menu bar. Then click the green Access button for the restaurant you would like to integrate with PrinterCo.
GloriaFood POS Printer - GloriaFood dashboard

STEP 1

 Step 2 – Enable Custom Integration
  1. From the left menu bar, click Other (the 3 dotted icon)
  2. Click Enabled integrations
  3. Click the Enable custom integration button
GloriaFood POS Printer - Enable custom integration to print receipts
GloriaFood POS Printer - Enable custom integration to print receipts

STEP 2

 Step 3 – Configure Integration
  1. Copy the integration configuration like the one shown in the screenshot below
  2. The Endpoint URL is where you will upload the PHP integration file

STEP 3

 Step 4 – PHP Integration File
  1. Copy and paste the code below into a PHP file.
  2. Make sure to edit lines 96 and 97 with your own API key and password.
  3. Also, edit line 105 with your own printer ID
  4. Upload the PHP file to your web hosting and paste the URL into the Endpoint URL mentioned in Step 3

Tip 1: How to find the API Key and Password.

Tip 2: How to find the Printer ID

<?php
// ==========================================
// PART 1. Pull order details from GloriaFood
// ==========================================
$data = file_get_contents("php://input");
$dataValue = json_decode($data, true);





// =========================================================
// PART 2. Set-up required variables from a GloriaFood order - You can find more details for the post fields in your MyPanel dashboard. Visit mypanel.printerco.net
// =========================================================
$order_id = $dataValue['orders'][0]['id'];
$currency = $dataValue['orders'][0]['currency'];

$order_type = $dataValue['orders'][0]['type'];
$payment_status = 'paid'; 
$payment_method = $dataValue['orders'][0]['payment'];
$auth_code = ''; //identification code of payment

$order_time = $dataValue['orders'][0]['accepted_at']; //h:m dd-mm-yy
$delivery_time = $dataValue['orders'][0]['fulfill_at']; //h:m dd-mm-yy

$deliverycost = 0.00;
$deliveryCostCalculation = $dataValue['orders'][0]['items'];
foreach($deliveryCostCalculation as $deliveryCostValues){
  $deliveryCostType = $deliveryCostValues['type'];
  if($deliveryCostType=='delivery_fee'){
    $deliverycost=$deliveryCostValues['price'];
  }
}
$card_fee = 0.00;
$extra_fee = 0.00;
$total_discount = $dataValue['orders'][0]['cart_discount_rate'];
$total_amount = $dataValue['orders'][0]['total_price'];

$cust_name = $dataValue['orders'][0]['client_first_name'].' '.$dataValue['orders'][0]['client_last_name'];
$cust_address = $dataValue['orders'][0]['client_address'];
if($cust_address=='')
{
  $cust_address = 'Address Not Entered';
}
$cust_phone = $dataValue['orders'][0]['client_phone'];
$isVarified = 'verified'; 
$cust_instruction = $dataValue['orders'][0]['instructions'];
$num_prev_order = '';





// =================================================
// Part 3. Save the ordered food items into an array
// =================================================
$str='';
$menu_item = array();
$itemsFinding = $dataValue['orders'][0]['items'];
foreach($itemsFinding as $itemsFindingStart){
  $itemsFindingStartType = $itemsFindingStart['type'];
  if($itemsFindingStartType=='item'){
    $quantity=$itemsFindingStart['quantity'];
    $category=$itemsFindingStart['group_name'];
    $name = $itemsFindingStart['name'];
    $price = $itemsFindingStart['total_item_price'];
    $item_instructions = $itemsFindingStart['instructions']; 
    //collect options/toppings of an item
    $additions = array();
    if(!empty($itemsFindingStart["options"])) {
      foreach($itemsFindingStart["options"] as $opt) {
        $additions[] = $opt["name"];
      }
    }
    if(!empty($additions)) {
      $option = "/r"  . implode("/r", $additions);
    }
    
    
        $menu_item[] = array(
    		'quantity'=>$quantity, 
    		'category'=>$category, 
    		'name'=>$name, 
    		'description'=>$option . "/r" . $item_instructions, 
    		'price'=>$price
    	    );
  }
}




// =============================
// PART 4. API access credential - Find this in your MyPanel dashboard under My account > Edit Information.
// =============================
$api_key = '34c453';
$api_password = '123456';




// ============================
// PART 5. PrinterCo printer ID - visit your MyPanel dashboard and then the Printer List page to find the printer ID.
// ============================
$printer_id = 11;





// =====================================
// PART 6. Set receipt header and footer
// =====================================
$receipt_header = "PrinterCo Restaurant%%Kemp House, 160 City Road%%London, EC1V 2NX%%0800 689 5326";
$receipt_footer = "Thank you";





// ==========================
// PART 7. Notification URL - When an order is either accepted or rejected on the printer, this info will be sent to this URL.
// ==========================
$notify_url = 'http://yourwebsite.com/notify.php';
// Even if this will not be used, this is a mandatory field needed to send orders to the API





// =========================================
// PART 8. Preparing post fields as an array 
// before sending to the PrinterCo API
// =========================================
$post_array = array();

$post_array['api_key'] = $api_key;
$post_array['api_password'] = $api_password;


$post_array['receipt_header'] = $receipt_header;
$post_array['receipt_footer'] = $receipt_footer;

$post_array['notify_url'] = $notify_url;
$post_array['printer_id'] = $printer_id;

$post_array['order_id'] = $order_id;
$post_array['currency'] = $currency;

//1=Delivery, 2=Collection/Pickup, 3=Reservation
if($order_type=='delivery'){
  $post_array['order_type'] = 1;
}
else if($order_type=='collection' || $order_type=='pickup'){
  $post_array['order_type'] = 2;
}
else if($order_type=='reservation'){
  $post_array['order_type'] = 3;
}

//6=Order Paid, 7=Order Not paid
if($payment_method=='ONLINE'){
  $post_array['payment_status'] = 6;
}
else{
  $post_array['payment_status'] = 7;
}
$post_array['payment_method'] = $payment_method;
$post_array['auth_code'] = $auth_code;

$post_array['order_time'] = $order_time;
$post_array['delivery_time'] = $delivery_time;

$post_array['deliverycost'] = $deliverycost;
$post_array['card_fee'] = $card_fee;
$post_array['extra_fee'] = $extra_fee;
$post_array['total_discount'] = $total_discount;
$post_array['total_amount'] = $total_amount;

$post_array['cust_name'] = $cust_name;
$post_array['cust_address'] = $cust_address;
$post_array['cust_phone'] = $cust_phone;

//4=verified, 5=not verified
$post_array['isVarified'] = 4;
$post_array['cust_instruction'] = $cust_instruction;
$post_array['num_prev_order'] = $num_prev_order;


$cnt = 1;
foreach($menu_item as $val){
  $post_array['cat_'.$cnt] = empty($val['category']) ? "-" : $val['category'];
  $post_array['item_'.$cnt] = $val['name'];
  $post_array['desc_'.$cnt] = $val['description'];
  $post_array['qnt_'.$cnt] = $val['quantity'];
  $post_array['price_'.$cnt] = $val['price'];
  
  $cnt++;
}





// ========================================
// Part 8. Post order data to PrinterCo API
// ========================================
$printerco_api_url = 'https://mypanel.printerco.net/submitorder.php';
$response = post_to_api($printerco_api_url,$post_array);




// ===================================
// Part 9. Post data to API using CURL
// ===================================
function post_to_api($url, $post_data) {
    
  set_time_limit(60);
  $output = array();
      
  $fields = "";
  $i = 0;
  foreach ($post_data as $key => $value) {
    $fields .= ($i > 0) ? "&" . "$key=" . urlencode($value) : "$key=" . urlencode($value);
    $i++;
  };
        
  $curlSession = curl_init();
  curl_setopt($curlSession, CURLOPT_URL, $url);
  curl_setopt($curlSession, CURLOPT_HEADER, 0);
  curl_setopt($curlSession, CURLOPT_POST, 1);
  curl_setopt($curlSession, CURLOPT_POSTFIELDS, $fields);
  curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curlSession, CURLOPT_TIMEOUT, 30);
  curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 2);
      
  $rawresponse = curl_exec($curlSession);	
      
  curl_close($curlSession);
  
  return $output;
}
?>
You can find more information on the GloriaFood API here.

Your Gloriafood Order Printer is now ready!

After you’ve configured these settings, your GloriaFood website should be ready to print orders to our Gloriafood order printer. Send a test order from your website and check to see if it prints out. If not, then make sure to check the WatchDog to see if you’ve missed anything.
  
If you’d like to change the text size and style of the receipt, then make sure you read our tutorial here.
 
If you need help then feel free to contact our support team. You can email support@printerco.net or reach us via live chat.

Leave a comment

Enter your keyword