Using a Script to Merge Orders Together

Using a Script to Merge Orders Together

Users can take advantage of the Infoplus scripting capability to automatically merge orders together without having to manually edit each of them. This article will explain one way that this can be accomplished through a custom field and a bit of code. 

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.


Note that changes made in Infoplus will NOT be communicated back to shopping cart connections automatically. 

First, create a Custom Field on your order table and give it an appropriate name, such as 'Merge With Order.'  This field will be used to tell Infoplus what order you would like to merge into the order you are working with. For example, if you are attempting to merge order 1.000 into order 2.000, you can edit 2.000 (or whichever order you want to use) and enter 1.000 into this custom field. Make sure you include the .000. 


Note that if you are attempting to merge more than two orders you would need additional custom fields to handle them. It is also worth mentioning that if you are attempting to merge orders with the same line items, you will get an error unless your site is configured to allow duplicate line items per order. If your site is not configured to allow this, you can enter a support ticket to request it. 


Once you have the custom field created you will need to create a script to execute this task.  Give the script an appropriate name, choose record for script type, order for record type and beta for the API Version. 



Next, copy and paste the javascript code shown below and make sure that the variable looking for the custom field you created is named correctly and updated throughout the code. Here is where that variable is established:

No other variables in this script should need to be manipulated. 

 

To run this script, select the order that contains the 'Merge With' value and choose 'Run Script' from the action menu dropdown. Choose the script you just created and hit submit.