There are cases where orders will come from Shopify into Infoplus without a billing address.  Since Infoplus requires that orders have a billing address, these orders would get rejected by Infoplus and an alert would be created explaining why.  Infoplus Scripts can be used to auto-populate a default billing address into these orders coming from Shopify if they do not already have a billing address.  The following script will make this happen by first identifying if the billing address is missing, then if so, populates a default address of your choice which will allow the order to import into Infoplus without errors.


The first step is creating a script with the Script Type of "Shopping Cart Connection Order".  Next, populate the code section of the script with the following, making changes to the address variable as needed.


utils.log("Running Shopify Shopping Cart Connection Order Script"); 
utils.log("Order Id: " + orderData.get("order").get("id"));  
utils.log("Full order object: " + orderData.get("order"));

var orderObject = orderData.get("order");
var containsBillingAddress = orderObject.has("billing_address");

utils.log ("Order has a billing address: " + containsBillingAddress);

// If order doesn't have a billing address, put in a default address
if (containsBillingAddress)
{
    utils.log("Order has billing address data, not updating.");
}

else
{
    utils.log("Order does not have billing address data, updating to default adddress");

    // Edit the address variable as needed to be the desired default billing address
    var address = utils.stringToJson('{"name":"Default Address","first_name":"Default","address2":"Unit 303","province_code":"MO","address1":"123 Fake Street","city":"St Louis","zip":"62263","province":"Missouri","country":"United States","last_name":"Address"}'); 
    orderData.get("order").put("billing_address", address); 
}

utils.log("Full order object after changes: " + orderData.get("order"));


After the script is written and saved, it must be applied to the the Shopify Shopping Cart Connection record in Infoplus.  Navigate to this record, select edit from the actions menu (or press the 'e' key), then in the script field select the script that was previously created.  Finally, don't forget to save the connection by clicking the Save button at the bottom of the changes.  


Once the script has been applied to the shopping cart connection, the script log table can be used to confirm the script is working as expected.  


Related Information: