Due to the ever-changing nature of writing and maintaining scripts, Infoplus does not provide support in this area. We recommend someone in your IT Department handles scripting requests internally so that you keep all control over the process.
When using some payment processors in Shopify, there are times when Infoplus will receive orders while they are in a 'pending' financial status. A subsequent notification will also be sent to Infoplus, once the order's financial system is 'paid'. By default, Infoplus will import the order when the first notification is received. You may prefer to have Infoplus reject the first notification and wait for the 'paid' financial status. This can be accomplished using an Infoplus Script.
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.
utils.log("Running Reject Pending Financial Status Orders Script"); ////////////////////////// // setup some constants // ////////////////////////// var STATUS_FIELD_NAME = "financial_status"; var REJECT_STATUS_VALUE = "pending" ////////////////////////////////////// // output some data about the order // ////////////////////////////////////// var order = orderData.get("order"); utils.log("Evaluating Order With Id: " + order.get("id")); if(order.has(STATUS_FIELD_NAME)) { var orderStatus = order.get(STATUS_FIELD_NAME); ///////////////////////////////////////////////////// // if order status matches what we want to reject, // // use utils to stop further processing of order // ///////////////////////////////////////////////////// if(orderStatus == REJECT_STATUS_VALUE) { var rejectReason = "Rejecting Order because its " + STATUS_FIELD_NAME + " is '" + REJECT_STATUS_VALUE + "'."; utils.log(rejectReason); utils.rejectOrder(rejectReason); return; } utils.log("Allowing order to import because it's status is '" + orderStatus + "' and NOT '" + REJECT_STATUS_VALUE + "'."); } else { /////////////////////////////////////////////// // if no status found, we will assume ok // // and let the order import process continue // /////////////////////////////////////////////// utils.log("Found order without a value for '" + STATUS_FIELD_NAME + "', allowing order to be imported."); }
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: