URL Parameter Program

Problem

Through several of my businesses, I sometimes have to manually quote several customers. This is because some customers need customization to pre-made packages or are in another state.  I was tired of passing along a .PDF of pricing tables where the customer had to try and decipher titles and compare them to the detailed packages. They were able to understand the pricing which was not always a good thing if they didn’t understand what they were getting. 

Ideas

Since I enjoy web development and design, I wanted to make a way to offer custom pricing directly on our webpage, so that I can just pass along a special link that enables this pricing on packages and add-ons all around the site. This was important to me because a customer would have all the information in front of them rather than trying to compare a .PDF pricing table with the products online. Here are two ideas I came up with that would befit my situation: 

  1. I could clone a pricing webpage, insert the pricing, and pass along that URL, but that becomes costly with storage and time. 
  2. I could use parameters in a URL to insert the pricing by having text fields that appear when a parameter exists, and display that parameter’s value. E.g. matthewklich.com/?parameter=value

I used the latter.

Implementation

There were two parts to this project, the web development for parameter injection and a URL string builder so I didn’t have to manually type about 100 values into specific parameters each customer. 

URL String Builder

I calculate pricing for distant or custom customers with an excel sheet based on distance, overnight stays, and the number of crew I need. With this template already built, I was able to have a new sheet in the template display the original price and sale price of each product. It appeared as follows where “|” denotes a column and a new line is a row:

product1 | product1_option1 | product1_option1_oprice | product1_option1_sprice

product1 | product1_option2 | product1_option2_oprice | product1_option2_sprice

product2 | product2_option1 | product2_option1_oprice | product2_option1_sprice

With this format, I export as a .CSV so I can use the data in program. 

I decided to use Java since BufferReaders, to read in data from file, were like seeing the back of my hand. This program reads the CSV line by line, separates each column by commas, and inputs parameter variables where required. I had it manually add the domain and subpage such as “matthewklich.com/url-parameter-program/?” where the question mark denotes the start of parameters and an & separates parameters. Furthermore, the program will combine the product, option together, and either original or sale label to produce the value of original and sale price of that option. Using the first line of the example above, the program would create:

URL.com/?product1+option1+original=originalPrice&product1+option1+sale=salePrice

matthewklich.com/url-parameter-program/?product1product1_option1o=product1_option1_oprice&product1product1_option1s=product1_option1_sprice

This URL, in implementation, has much smaller parameter names using single letters to denote a product, an option, and whether it’s an original or sale price of the product and option. Here is an example of the actual program output in terminal, less the URL and with dummy pricing:

> % javac URLBuilder.java
> % java URLBuilder /Users/computer/Desktop/Pricing.csv

-------------------------------------------
https://<URLREDACTED>/?prices=true&q=t&sg1o=4,365&sg1s=3,440&sg2o=5,160&sg2s=4,090&sg3o=7,035&sg3s=5,590&sg4o=8,050&sg4s=6,390&sg5o=11,035&sg5s=8,790&wg4o=10,695&wg4s=8,540&wg5o=12,880&wg5s=10,290&wg6o=16,595&wg6s=13,240&ip3o=1,099&ip3s=550&ip4o=1,199&ip4s=650&ip5o=1,449&ip5s=900&ip6o=1,549&ip6s=1,000&ip8o=1,743&ip8s=1,500&ip9o=2,356&ip9s=2,113&ip14o=3,141&ip14s=2,898&ip16o=3,455&ip16s=3,212
-------------------------------------------

> %

Web Development

Using the generated link, on the web-side, we can inject pricing into our site by GETing said parameters and only displaying them if they exist. This is shown on a before and after image below (drag the arrows):

Conclusion

If I find time, I want to implement a drag-and-drop .CSV function to a protected webpage that will produce a generated URL right on the site – that way I do not need to run this in terminal and can let employees handle advanced quotes. 

Comment
Name
Email