This guide will guide you through the smooth setup process, enabling efficient orders management for creating a sales order in Priority when a new order is processed in WooCommerce.
Prerequisites #
Before you begin, ensure the following connections are established:
- Connection between Engini and Priority.
Learn how to connect priority to Engini - Connection between Engini and WooComerce.
Learn how to connect WooComerce to Engini
Add an order updated Trigger #
To get started, add a trigger:
- Add a new activity and choose “Order updated” trigger of WooCommerce.
- Click on the ” Add condition” button
- On the left field, select from the drop down the field you want to add the condition on. For this process choose the “status” field.
- On the middle field, choose from the drop down the “=” condition.
- Click on the right field, and the tooltip will pop up showing the options of the value you can choose. Choose the “Processing” value.
The workflow will run only if the condition is True. - Repeat on steps 2-5 to Add more conditions in addition to the status condition if necessary.
You can populate the value field in one of the following options:- Static value – number / string. when using strings, you need to surround them with single quotes (‘).
- Expression – using functions and/or Previous activity properties and/or static values (Using the tooltip that opens when clicking on the field).
- Click on the “next step” button.
Initialize Variable #
Now, let’s initialize a variable that will later hold the customer number of the customer in Priority:
- Choose “Initialize Variable” action of Engini.
- Name field
Click on the empty field and choose from the tooltip a name for the variable. For example “customer number” - Type field
Choose from the drop down the “string” option. - Click on the “next step” button.
Get Items “Customers” #
Next, add the “Get Items Customers” action of Priority and set up filters:
- Add a new activity and choose “Get Items Customers” action of Priority.
- Click on the “Add filter” button to add a filter.
- On the left field, select from the drop down the field you want to add the filter on. For this process choose the “E-mail Address” field.
- On the middle field, choose from the drop down the “=” condition.
- Click on the right field, and the tooltip will pop up showing the options of the value you can choose:
- Click on “functions”
- Choose the “ToLower” function, that converts a string to lowercase letters and returns the new string.
- Choose the “email” value from activity 1 as an input.
- Repeat on steps 3-5 to Add more filters in addition to the first filter.
You can populate the value field in one of the following options:- Static value – number / string. when using strings, you need to surround them with single quotes (‘).
- Expression – using functions and/or Previous activity properties and/or static values (Using the tooltip that opens when clicking on the field).
- Enter the number “1” in the on the “Top N” field. You can red more about the meaning of the “Top N” field here.
Create Customers #
In case, no customer was found with the same email as the billing customer’s email create a new customer.
- Add a new activity and choose “Create Customers” action of priority.
- Click on the “Add fields” button to fill the fields in the “Customers” form.
- On the left field, select from the drop down the field you want to populate in the table.
For this process choose the fields:- Customer Name
- E-mail Address
- Phone Number
- Street Address
- City
- Address (Line 2)
- Click on the right field, and the tooltip will pop up showing the options of the values you can choose.
- For the “Customer Name” field:
- Click on the functions
- Choose the concat function which Combines two or more strings, or expression text results into a single string.
- On the left side of the comma enter the first name from the billing from activity 1.
- On the right side of the comma enter ” ” , and add another comma
- On the right of the second comma enter the last name from the billing from activity 1.
- For the “E-mail Address” field:
- Click on “functions”
- Choose the “ToLower” function, that converts a string to lowercase letters and returns the new string.
- Choose the “email” value from the billing from activity 1 as an input.
- For the “Phone Number” field choose the phone value from the billing from activity 1.
- For the “Street Address” field choose the address value from the billing from activity 1.
- For the “City” field choose the city value from the billing from activity 1.
- For the “Address (Line 2)” field choose the address_2 value from the billing from activity 1.
- For the “Customer Name” field:
- Repeat on steps 2-4 to Add more fields in addition to the fields we already added, if necessary.
- Click on the three dots on the right side of the activity block.
- Click on “configure run after” option.
- Remove the “v” from is successful check box and add the “v” to is failed check box.
- Click on the Done button.
- Hover over the arrow after this activity and click on the “plus” icon.
- Repeat the steps 4-7 of set variable.
Set Variable #
In case a customer was found with the same email as the billing customer’s email, populate the number of the customer in the variable you initialized before:
- Hover over the arrow that connects “create customers” and “get items Customers”.
- Click on the plus icon.
- Click on the “Add as parallel branch” option.
- Choose “Set Variable” action of priority.
- Click on the drop down and choose the name you gave the variable you initialize.
- Click on the empty field next to the “value” and choose from the tool tip the number of the customer from the Get Items Customers activity.
- Click on the “next step” button.
Create Sales Orders #
Add a new activity and choose the “Create Sales Orders” action of Priority:
- Click on the “Add fields” button to fill the fields in the “Sales Orders” form.
- On the left field, select from the drop down the field you want to populate in the form.
For this process choose the fields:- Sales Rep Order Num
- Customer Number
- Click on the right field, and the tooltip will pop up showing the options of the values you can choose.
- For the “Sales Rep Order Num” field choose the number value from activity number 1.
- For the “Customer Number” field choose the variable you initialize few activities before.
- Repeat on steps 1-3 to Add more fields in addition to the fields we already added, if necessary.
- Click on the “next step” button.
Create “Shiping Address” (Subform of “Sales Orders”) #
Add a new activity and choose the “Create “Shiping Address” (Subform of “Sales Orders”)” action of Priority:
- Click on the empty field next to “Order (Sales Order)” and a tooltip will pop up showing the options of the value you can choose. Choose the “Sales Order” value from “Create “Sales Orders”” activity.
- Click on the “Add fields” button to fill the fields in the “Shiping Address” subform.
- On the left field, select from the drop down the field you want to populate in the subform.
For this process choose the fields:- Street Address
- Country
- City
- Name
- Phone Number
- Address (Line 2)
- Zip Code
- Click on the right field, and a tooltip will pop up showing the options of the values you can choose.
- For the “Street Address” field choose the address value from the shipping from activity number 1.
- For the “Country” field choose the state value from the shipping from activity number 1.
- For the “City” field choose the city value from the shipping from activity number 1.
- For the “Name” field:
- Click on the functions
- Choose the concat function which Combines two or more strings, or expression text results into a single string.
- On the left side of the comma enter the first name from the billing from activity 1.
- On the right side of the comma enter ” ” , and add another comma
- On the right of the second comma enter the last name from the billing from activity 1.
- For the “Phone Number” field choose the phone value from the shipping (if there is no phone, choose it from the billing) from activity number 1.
- For the “Address (Line 2)” field choose the address 2 value from the shipping from activity number 1.
- For the “Zip Code” field choose the postcode value from the shipping from activity number 1.
- Repeat on steps 3-5 to Add more fields in addition to the fields we already added, if necessary.
For Each Loop #
Add a new activity and choose the “For Each Loop” action of Engini:
- Click on the empty field next to the Data List and choose from the tooltip the array of the line items from activity number 1.
- Click on the “next step” button inside the “for each loop” block.
Create “Order Items” (Subform of “Sales Orders”) #
Add a new activity and choose the “Create “Order Items” (Subform of “Sales Orders”)” action of Priority:
- Order field
Click on the empty field and choose from the tooltip the number of the order from “Create “Sales Orders”” activity. - Click on the “Add fields” button to fill the fields in the “Order Items” subform.
- On the left field, select from the drop down the field you want to populate in the table.
For this process choose the fields:- Unit Price
- Quantity
- Line Item (ID)
- Order Currency
- Click on the right field, and the tooltip will pop up showing the options of the values you can choose.
- For the “Unit Price” field choose the price value from line items from activity 1.
- For the “Quanity” field choose the quantity value from the line items from activity 1.
- For the “Line Item” field choose the sku value from the line items from activity 1.
- For the “Order Currency” field choose the Currency value from activity 1.
- Repeat on steps 3-5 to Add more fields in addition to the fields we already added, if necessary.