top of page
  • Robert Hebert

How to Create a Sales Rep Order Process for Clients in Wix




Who is our client and what problem did they want to solve?


Our client wanted certain members of their website, the Sales Reps, to be able to create orders for their customers from the front end of the website.


What solution did we provide?


Setting this up required the creation of two content manager databases, Sales Reps (a table that would store the name of the sales rep along with their member id) and SalesRepCustomers (a table that would store a customer's id, the member id of the sales rep associated with that customer, and some information to display on the front end such as the customer's first name, last name, and company).


What were the next steps?


After this, members who were sales reps were manually added to the SalesReps table.


Two important points:

  1. We needed a way for customers to automatically be associated with sales reps upon creation, and

  2. also to make sure they were associated with the right sales rep in the event their contact was updated


To do this, we went back to the 'events.js' file we created and used two events from Wix's CRM (onContactCreated & onContactUpdated) to query the SalesReps table, find the sales rep the customer had selected when they signed up, and make or update an entry in the SalesRepCustomers table.


Now that customers are correctly assigned to the Sales Rep members, we created the page that would be used for the Sales Reps to create customer orders.


This contains a dropdown that is populated with the Sales Rep's customers fetched from the SalesRepCustomers table using the wixData module. It also contains an autocomplete address field for the billing and shipping address as well as a text input for the shipping/billing address line 2.


When all of these fields are filled out, the Sales Rep hits the "Submit Order" button on the page, the MultiState box containing the form is changed to the 'submitted' state, a spinner is shown along with the text "Processing order", and then after a few seconds based on whether the order was successfully created, the Multistate box is changed to either the 'success' or 'failure' state.


...but what's happening on the backend?


When the "Submit Order" button is hit, we use the fetch function from the 'wix-fetch' module to submit the order to a backend function defined in 'backend/http-functions.js'.


This is a special file that Wix uses to expose endpoints for your site to interact with its backend.


The function defined in this file takes the information the front end submits to it (the customer id of the customer the order is supposed to be created for, the sales rep's current cart, and the billing and shipping information they entered) and then uses the Wix CRM Backend module's createOrder function to create an order for the customer.


We thought this would satisfy the business requirements, but because Wix does not allow you to generate invoices for unpaid orders, we had to go a step further.


After the order is created, we then use the createInvoice function from the Wix Billing Backend invoices module to create an invoice for the customer that can be sent to the customer for them to pay for the order.


What was the final step?


This brings us to the final requirement of this project.


We needed to take the data from these invoices and send them to two different Google sheets.


To do this:

  1. We added events to the 'backend/events.js' file.

  2. We added code to send the invoice data to one sheet whenever an invoice is either created or paid.

And then, additional coding was used to send invoice data to a separate Google sheet whenever an invoice was overdue.


This gave our client the ability to share this data with their sales reps and keep track of the orders created in the process.





Does your company have sales reps? Do you need something like this for your website? Let's chat! Contact us at 225-250-1888 or email robert@roberthebertmedia.com.



About our company


RHM specializes in helping businesses of all sizes and across all industries achieve their digital and web marketing needs. Whether you are designing a new website, building an app, performing custom development, or running Google Ads, our goal is to showcase how you are the best at what you do and help people connect with you. Contact us at 225-250-1888 to get started!



15 views0 comments
bottom of page