How to disable logged in WordPress user notification on Zoho SalesIQ?

We use WordPress for our website. We also use Zoho SalesIQ to track visitors and chat with them. But, It gets annoying when our employees with WordPress login visits the web page and we get notified on SalesIQ. We decided to stop that from happening. This is what we did. I’m sure there are other approaches, but this is what we do.

Step 1: Find out the SalesIQ plugin

If you look at your hosting file manager or the plugin page on WordPress admin site, you can find out the SalesIQ plugin folder. Get into that and find the index.php file.

Step 2: Edit the index.php file

Warning: This is not a preferred method to edit a plugin. You should always copy the plugin, edit files and upload them as a new one. Editing an existing plugin also affects the changes when the plugin is updated by the developer(Zoho). Keeping that in mind, please proceed to the further steps with caution.

Find the line that starts with “function ld_embedchat()“. It is a php function and that is where Zoho SalesIQ decides whether or not to show the chat

Step 3: Edit the ld_embedchat() function

In the first if, where they return an empty value, add your custom script.

Step 3.1: To Hide SalesIQ for Logged In Users

Add “|| is_user_logged_in()” as criteria. It should look like


if ( !preg_match( "/^<script[^>]*>.+float\.ls.+<\/script>$/s", $ldcode_str ) || is_user_logged_in() )
{
return;
}

Instead of

if ( !preg_match( "/^<script[^>]*>.+float\.ls.+<\/script>$/s", $ldcode_str ) )
{
return;
}

Step 3.2: To Hide SalesIQ based on custom IP address

Get the IP address of the visitor using the below script

$ip_to_hide = "yourIPAddress";//add the IP address for which you want to hide SalesIQ

if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}

Add it to your if criteria as,


if ( !preg_match( "/^<script[^>]*>.+float\.ls.+<\/script>$/s", $ldcode_str ) || is_user_logged_in() || $ip == $ip_to_hide )
{
return;
}

Step 4: Update plugin

Once you have completed the above step. Click Update File – If you’re editing from WP admin page- or upload the edited file to your server.

If you reload your website – clear cache probably- you will no longer be notified for your wordpress users on Zoho SalesIQ.

If you have any questions or suggestions, please contact us from our Contact page.

Read More

Get Japanese Address from post code using Zoho Creator Deluge

The requirement

Input 7 digit Japanese postal code (###-####) and get the address.

Language used

Zoho Creator Deluge

Data Source -> https://github.com/aorborc/jp_code_english/

Deluge Code

Below is the function that takes 7 digits postal code as two inputs (first 3 digits and second 4 digits) and returns an address.

map postal.get_address(string first_three, string second_four)
{
    this_address = map();
    first_three_len = ifnull(input.first_three,"").length();
    second_four_len = ifnull(input.second_four,"").length();
    if ((first_three_len  ==  3)  &&  (second_four_len  ==  4))
    {
        postal_code = input.first_three + input.second_four;
        data_url = "https://raw.githubusercontent.com/aorborc/jp_code_english/0804e74d63ec902eccfcf847ea49a0a6a7488d16/data/" + input.first_three + ".js";
        str = getUrl(data_url);
        value_map = str.toMap();
        my_map = (value_map.get(postal_code)).toMap();
        jp_address = ((my_map.get("perfecture_jp")) + my_map.get("jp_add_1")) + my_map.get("jp_add_2");
        eng_address = ((my_map.get("prefecture")) +" " +  my_map.get("city")) + " " +  my_map.get("town");
        this_address.put("jp_address", jp_address);
        this_address.put("eng_address", eng_address);
    }
    return this_address;
}

Images

Screen Shot 2017-02-07 at 8.38.49 AMScreen Shot 2017-02-11 at 6.07.50 PM

Read More

Zoho Creator URL parameters fix

The Problem

If you are opening a Zoho Creator Form from a third party, and it includes the query string as “?first-name=Rob”, there is no direct way to get the value of “first-name” into a field in your Form. It will not work because Deluge names can’t have “-” in them.

Question posted at : https://forums.zoho.com/topic/dealing-with-a-poorly-formatted-query-string

The Solution

There are only two places in Zoho Creator that can read URL parameters. 1. Form and 2. Pages. Both don’t accept “-” in parameter/field names. So, the optimal solution will be,

  1. Write a php file to convert “-” formatted query strings into “_” formatted query strings and open Zoho Creator Form with new query strings
  2. Host it on your server
  3. Link your hosted php file to your third party

The Php code

I have given the php code below. You can change the Location url to your Zoho Creator Form Url

$query_string = $_SERVER['QUERY_STRING'];
parse_str($query_string, $query_array);
foreach ($query_array as $key => $value) {
$newkey = str_replace("-", "_", $key);
$query_array[$newkey] = $value;
unset($query_array[$key]);
}
header("Location:https://app.zohocreator.com/aorborctechnologies/url-params/#Form:Contact?" . http_build_query($query_array) );

Demo

Click http://aorborc.com/samples/php/demo/param_fix.php?first-name=robert&last-name=m and you will be redirected to our Zoho Creator Form with the formatted query strings.

 

Read More

Xero and Zoho Integration – A guide for developers – part 1

This guide will walk you through the steps for integrating Xero accounting Software with Zoho Creator applications. I have decided to split this guide into multiple parts. You can expect the next part soon.

Prerequisites

  1. A hosting account -> php based.
  2. Basic knowledge of understanding php code and XML
  3. Basic knowledge of posturl task in Zoho Creator

The Challenge

Xero requires OAuth for authentication. So, a simple URL request with a client ID or secret code does not allow you to integrate Zoho Creator with Xero application. It also requires certificate files and validate through xero php classes.

The Solution

We looked at the php library for Xero, written by Xero team and wanted to make use of it. Also, everyone at our company understands php and Zoho Creator. So, we thought we will pick this one. They also have libraries for other languages, if you don’t want to use php. But, this article assumes you are using the php library.

The Steps

1. Download the copy of Xero PHP API library

Download the Php API library for Xero from https://github.com/XeroAPI/XeroOAuth-PHP and unzip it.

2. Working with the downloaded library

  • After downloading the file, you can unzip it to the Xero folder
  • If you have a hosting account and if you can edit the files online, upload the xero folder to your hosting server
  • If you want to test it in your localhost, you can move the xero folder to your localhost path
  • Once it is done, you can verify if it is uploaded correctly by accessing your xero path from your server (localhost/hosted)

3. Understanding the downloaded Library

The Php library you just downloaded has 3 folders(directories) and a few files.  We will go through the folders and private.php file in this guide.

certs folder

This folder holds the private certificates you will generate for the purpose of using this api. According to Xero,

Private and Partner applications must sign messages using the OAuth RSA-SHA1 method.

This requires that you create a public/private key-pair, and upload the public certificate during application registration. We refer to this certificate as an application certificate.

To get started with creating a public/private key-pair we recommend the use of OpenSSL

For the steps to create self-signed certificates, visit https://developer.xero.com/documentation/api-guides/create-publicprivate-key/

After you are done with creating certificates (privatekey.pem and publickey.cer files), upload them to the certs folder. These files are important as Xero will check for the certificates while making the api connection

lib folder

This folder contains php classes that connect with Xero server at different times and authenticate the user

test folder

The tests.php file in this folder has sample requests for all the Xero APIs. You can use the code from this file, instead of writing your own code while pushing data to Xero.

private.php file

As soon as you create a new Private application from Xero (it’s free and easy, steps at https://developer.xero.com/documentation/auth-and-limits/private-applications/), you will find the consumer_key and shared_secret on the application page. Copy them and paste them in the private.php file. Like below

$signatures = array (
'consumer_key' => "Your Consumer Key",
'shared_secret' => "Your Shared Secret",
// API versions
'core_version' => '2.0',
'payroll_version' => '1.0',
'file_version' => '1.0'
);

4. Testing the Xero Connection

To be continued in part 2…

Read More

US address verifier using usps API

We came across a requirement where one of our customers wanted to verify the address entered. It took a while to get the right API method that would work. Fortunately, USPS offers a good API and documentation on this. We are listing the steps below to achieve the same in your application.

Prerequisites:

  1. A USPS api USER ID, created at https://registration.shippingapis.com/
    You will receive an email after the registration with the userid (created automatically by usps)
  2. Knowledge of Zoho Creator’s PostURL and XML parsing and deluge scripting

How it is done : 

We have created the following fields on the Form

  1. Address fields – Street Address, Apt no, City, State, Zip-
  2. a decision box “Verify Address”, to initiate the address verifier
  3. an Add notes field “address_display”, to display the verified address
  4. a decision box “Update Address”, to update the address fields with the correct address

Script Execution:

On user input of “Verify Address” field triggers the address verifier and updates the address_display notes field and has the following script


if (input.Verify_Address)
{
    xml_string = thisapp.usps.construct_xml(input.Street_Address, input.Apartment_or_Suite_Number, input.City, input.State, input.Zip_Code);
    usps_resp = thisapp.usps.verify_address(xml_string);
    resp_map = thisapp.usps.beautify_xml(usps_resp);
    input.Verified_Address = resp_map.toString();
    input.address_display = resp_map.get("address_display_html");
}

1. Construct the XML


string usps.construct_xml(string street_address, string apt_no, string city, string state, string zip)
{
 xml_string = "<AddressValidateRequest USERID=\"your_user_id_from_usps_email\"><IncludeOptionalElements>true</IncludeOptionalElements> <ReturnCarrierRoute>true</ReturnCarrierRoute><Address ID=\"0\"><FirmName />";
 xml_string = xml_string + "<Address1>" + ifnull(input.apt_no,"") + "</Address1>";
 xml_string = xml_string + "<Address2>" + ifnull(input.street_address,"") + "</Address2>";
 xml_string = xml_string + "<City>" + ifnull(input.city,"") + "</City>";
 xml_string = xml_string + "<State>" + ifnull(input.state,"") + "</State>";
 xml_string = xml_string + "<Zip5>" + ifnull(input.zip,"") + "</Zip5>";
 xml_string = xml_string + "<Zip4></Zip4>";
 xml_string = xml_string + "</Address></AddressValidateRequest>";
 return xml_string;
}

2. Use the Zoho Creator’s post url to verify address from USPS website


string usps.verify_address(string xml_string)
{
 usps_url = "http://production.shippingapis.com/ShippingAPI.dll";
 params = map();
 params.put("API", "Verify");
 params.put("XML", input.xml_string);
 usps_resp = postUrl(usps_url, params);
 return usps_resp;
}

3. Parse the XML and store the response in a map/object variable


map usps.beautify_xml(string xml_string)
{
 xml_map = map();
 address_display_html = ("<style>.list-group-item{list-style: none;color:#fff;}</style><div id='address_display_custom' style='background-color:#5cb85c;border-color:#5cb85c;width:300px;padding:4px;border-radius:4px;border:1px solid rgba(0,0,0,.125);'><ul class='list-group'>");
 street_address_val = input.xml_string.executeXPath("/AddressValidateResponse/Address/Address2/text()");
 xml_map.put("street_address_val", street_address_val);
 address_display_html = address_display_html + "<li class='list-group-item'>" + street_address_val + "</li>";
 apt_no = input.xml_string.executeXPath("/AddressValidateResponse/Address/Address1/text()");
 xml_map.put("apt_no", apt_no);
 address_display_html = address_display_html + "<li class='list-group-item'>" + apt_no + "</li>";
 city_val = input.xml_string.executeXPath("/AddressValidateResponse/Address/City/text()");
 xml_map.put("city_val", city_val);
 address_display_html = address_display_html + "<li class='list-group-item'>" + city_val + "</li>";
 state_val = input.xml_string.executeXPath("/AddressValidateResponse/Address/State/text()");
 xml_map.put("state_val", state_val);
 address_display_html = address_display_html + "<li class='list-group-item'>" + state_val + "</li>";
 zip_val = input.xml_string.executeXPath("/AddressValidateResponse/Address/Zip5/text()");
 xml_map.put("zip_val", zip_val);
 address_display_html = address_display_html + "<li class='list-group-item'>" + zip_val + "</li>";
 address_display_html = address_display_html + "</ul> </div> ";
 xml_map.put("address_display_html", address_display_html);
 return xml_map;
}

To update fields with correct address, the Update Address field’s on user input has the following script

Note: Verified_Address is a hidden multi-line text field to store the map response.


if (input.Update_Address  &&  (input.Verified_Address  !=  ""))
{
    xml_map = input.Verified_Address.toMap();
    input.Apartment_or_Suite_Number = xml_map.get("apt_no");
    input.Street_Address = xml_map.get("street_address_val");
    input.City = xml_map.get("city_val");
    input.State = xml_map.get("state_val");
    input.Zip_Code = xml_map.get("zip_val");
}

Live Preview

Read More

Let Zoho know you’re working with us

Hello there,

When you sign up and use Zoho services, you can add partners as your contact and let Zoho know who you’re working with. As you know, we offer voice/chat/email technical support services to all our clients. But, there is a step you need to follow before we can officially offer our support services to you.

  • If you don’t have a Zoho account yet, you can access http://bit.ly/2d4lXuP link to sign up for a new account. If you already have a Zoho account, follow the below steps
  • Go to https://payments.zoho.com/html/store/transfertoken.html
  • Select all the Zoho services you use
  • Click on generate at the bottom right
  • From the pop-up screen, enter your Name / Company Name
  • Check the box that says Send token to partner
  • Enter our email [email protected], in the Partner Email field
  • Hit submit

We will receive a notification and we will confirm it to you via email.

Thank you for choosing to work with us.

Read More

Display Currency value with commas and two decimals in Zoho Creator

string nullFix.currencyToStr(float num)
{
    //num = 1234567.98;
    myStr = "0.00";
    if (input.num  !=  null)
    {
        input.num = input.num.round(2);
        myStr = input.num.toString().replaceAll(("(?<!\.\d)(?<=\d)(?=(?:\d\d\d)+\b)"),",");
    }
    return myStr;
}

Live Preview… Try different currency values below and hit tab key

Read More

Free Bootstrap Invoice template

Preview/Download as HTML


<!Doctype html>
<html>
<head>
<title>Free Invoice template</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<style type="text/css">
.panel{
padding: 0px !important;
}
th,td{
border-right: 1px solid white !important;
}
.tdNoWrap{
white-space: nowrap;
}
*{
font-size:9px !important;
font-family:Calibri;
-webkit-print-color-adjust:exact;
}
.trHeader{
background-color : #C6CEE7 !important;
-webkit-print-color-adjust:exact;
}
.trRed{
//background-color: red;
color:red;
font-weight:bold;
}
.trGreen{
//background-color: green;
color:green;
font-weight:bold;
}
*{
font-family:Calibri;
-webkit-print-color-adjust:exact;
}
.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {
padding: 5px;
line-height: 1;
vertical-align: top;
border :none;
}
.paid{
float:center;
color:green;
}
.progress{
}
.row {
margin : auto;
}
a:hover, a:focus {
color: #2a6496;
text-decoration: none;
}
table { page-break-after:auto }
tr { page-break-inside:avoid; page-break-after:auto }
td { page-break-inside:avoid; page-break-after:auto }
thead { display:table-header-group }
#wmbg{
position: absolute;
z-index: 1;
background: transparent;
display: block;
min-height: 50%;
min-width: 50%;
margin-top: 25%;
margin-left: 25%;
}
#content{
position:absolute;
z-index:1;
}
#bg-text
{
color:orange;
font-size:72px !important;
transform:rotate(-45deg);
-webkit-transform:rotate(-45deg);
opacity: 0.1;
text-align: center;
}
@media print{
.tdNoWrap{
white-space: nowrap;
}
*{
font-size:9px !important;
font-family:Calibri;
-webkit-print-color-adjust:exact;
}
.trHeader{
background-color : #C6CEE7 !important;
-webkit-print-color-adjust:exact;
}
}
</style>
</head>
<body>
<div class="container">
<div class="row" style="margin-top: 15px;margin-bottom: 15px;">
<div class="col-xs-5">
<div class="col-xs-4">
<div class="media" style="margin-bottom:10px;">
<img style="width: 100px;" class="media-object img-responsive" src="http://www.aorborc.com/wp-content/themes/impulso/img/logo.png">
</div>
</div>
<div class="col-xs-8">
<div class="media-body">
<table style="font-size: 11px !important;font-family: Calibri; padding-left:5px;">
<tbody>
<tr>
<td colspan="2">
AorBorC Technologies LLC
</td>
</tr>
<tr>
<td colspan="2">
Address
<br>City State Zip Country
</td>
</tr>
<tr>
<th style="white-space: nowrap;">
License #:
</th>
<td style="padding-left:5px;white-space: nowrap;">
ABCD 12345
</td>
</tr>
<tr>
<th style="white-space: nowrap;">
Tracking #:
</th>
<td style="padding-left:5px;white-space: nowrap;">
12345
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-xs-2" align="center">
<h3 style="-webkit-transform: rotate(-45deg);color:red;font-size: 24px !important;"> Invoice <br> 90
</h3>
</div>
<div class="col-xs-5">
<div class="col-xs-4">
<div class="media" style="margin-bottom:10px;">
<img style="width:100px;" class="media-object img-responsive" src="http://aorborc.com/wp-admin/square_logo.png">
</div>
</div>
<div class="col-xs-8">
<div class="media-body">
<table style="font-size: 11px !important;font-family: Calibri; padding-left:5px;">
<tbody>
<tr>
<td colspan="2">
Client Name
<br>
Business Name
</td>
</tr>
<tr>
<td colspan="2">
Address
<br>City State Zip Country </td>
</tr>
<tr>
<th style="white-space: nowrap;">
Invoice # :
</th>
<td style="padding-left:5px;white-space: nowrap;">
90
</td>
</tr>
<tr>
<th style="white-space: nowrap;">
Submitted :
</th>
<td style="padding-left:5px;white-space: nowrap;">
05-Apr-2016
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row ">
<div class="col-xs-12 panel">
<div id="wmbg">
<p id="bg-text">
Pending
</p>
</div>
<table class="table" style="font-size: 11px !important; font-family: Calibri;">
<thead>
<tr class="trHeader" style="background-color: #C6CEE7;">
<th style="text-align:left;">Category</th>
<th style="text-align:right;">Item Name</th>
<th style="text-align:right;">Description</th>
<th style="text-align:right;">Qty</th>
<th style="text-align:right;">Price</th>
<th style="text-align:right;">Amount</th>
</tr>
</thead>
<tbody>
<tr>
<th style="text-align:left;" colspan="6">Design</th>
</tr>
<tr>
<td colspan="6"> </td>
</tr>
<tr>
<td>
</td>
<td style="text-align: right;">Wireframes</td>
<td style="text-align: right;max-width:300px;word-wrap:break-word;">
Creating wireframes
</td>
<td class="tdNoWrap" style="text-align: right;">1</td>
<td class="tdNoWrap" style="text-align: right;">$ 100.00
</td>
<td class="tdNoWrap" style="text-align: right;">$ 100.00</td>
</tr><tr>
<td>
</td>
<td style="text-align: right;">HTML</td>
<td style="text-align: right;max-width:300px;word-wrap:break-word;">HTML Design with bootstrap</td>
<td class="tdNoWrap" style="text-align: right;">1</td>
<td class="tdNoWrap" style="text-align: right;">$ 100.00
</td>
<td class="tdNoWrap" style="text-align: right;">$ 100.00</td>
</tr>
<tr>
<td colspan="6"> </td>
</tr>
<tr>
<th style="text-align:right;" colspan="5">Design Subtotal</th>
<th class="tdNoWrap" colspan="1" style="text-align: right;">$ 200.00</th>
</tr>

<tr>
<td colspan="6"> </td>
</tr>

<tr>
<th colspan="4" style="text-align:left;width: 80%;">
<span style="float:left;">Tax</span>
</th>
<td>
<span style="float:right;">
3.00 %</span>
</td>
<td>
<span style="float:right;">$6.00
</span>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<th colspan="4" style="text-align:left;width: 80%;">
<span style="float:left;">Discount</span>
</th>
<td>
<span style="float:right;">
5.00 %</span>
</td>
<td>
<span style="float:right;">$ 10.30
</span>
</td>
</tr>
<tr>
<td> </td>
</tr>

<tr>
<th colspan="5" style="text-align:left;">
<span style="float:left;">Grand Total</span>
</th>
<td>
<span style="float:right;">$ 210.30
</span>
</td>
</tr>
<tr>
<td colspan="6"> </td>
</tr>
<tr style="border-bottom: 5px solid white;">
<td> </td>
<th>
<span style="float:center;">Payment received
</span>
</th>
<td> </td>
<th class="trGreen">
<span style="float:center;">Paid </span>
</th>
<td> </td>
<td>
<span style="float:right;">$ 100.00
</span>
</td>
</tr>
<tr style="border-bottom: 5px solid white;">
<td> </td>
<th>
<span style="float:center;">Amount Credited (further discounts)
</span>
</th>
<td> </td>
<th class="trGreen">
<span style="float:center;"> </span>
</th>
<td> </td>
<td>
<span style="float:right;">-$ 10.00
</span>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<th colspan="5" style="text-align:left;">
<span style="float:left;">Pro Forma & Remaining Balance</span>
</th>
<th>
<span style="float:right;">$ 100.30
</span>
</th>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>

Read More