Use Case:  For any Orders from your Shopify site, if they have a "shipping code" of "Priority", update them to ship from warehouse 47.


Infoplus stores all data available from the Shopping Cart's API when it pulls orders.  These data all go into the order's "extra data" sub-table.  The script below includes a function which loops over the extra data on an order, looking for a specified value (in this case, the one with the code of "SHOP-SHIPPING_LINES.0.CODE").  


This script could be assigned to run with a Trigger that searched for new Orders with an Order Source that corresponded to your Shopify shopping cart connection.


function getOrderExtraData(order, code)
{
   var extraDataList = order.extraOrderData;
   if(extraDataList != null)
   {
      for(var i=0; i<extraDataList.size(); i++)
      {
         var extraData = extraDataList.get(i);
         if(extraData.code == code)
         {
            return(extraData.value);
         }
      }
   }
   return(null);
}

var shippingCode = getOrderExtraData(order, "SHOP-SHIPPING_LINES.0.CODE")
if(shippingCode == null)
{
   utils.log("Order [" + order.orderNo + "] does not have a shipping code.");
   return;
}


if(shippingCode == "Priority")
{
   utils.log("Order [" + order.orderNo + "] has shipping code [" + shippingCode + "] - switching order Warehouse");
   order.warehouseId = 47;
   infoplusApi.update("order", order);
   
   infoplusApi.addTag("order", order.orderNo, "Priority-Shipping");
   infoplusApi.addAudit("order", order.orderNo, "This order's shipping code was 'Priority', so its warehouse was changed via Infoplus Script");
}