Quotes

What are Quotes?

A quote in LemonStand is an order that hasn't been paid for by a speicific customer. It contains a selection of items, a customer, and can have a billing plan, expiry date, or coupon code. They can be sent to customers in an email, using the "shop:send-quote" email template.

Creating a Quote

Quotes can be created through the Quote API. There are a number of options available in a quote, so read through the API to get a good handle on what's possible.

Quote Page

Once we've created a quote and can see a quote in this dashboard, we'll want to be able to provide a link for our customers to checkout these quotes in our store. To do this we first set up our Quote page:

To create a Quote page, navigate to "Page Templates" and Add a new page. Give this page a couple settings:

  • URL of "/quote/:quoteLink"
  • Action "shop:cart"
  • Content: copied from the Cart page

Next, we apply this quote page to our "Quote Page" setting, under "Store Design" > "Site Settings":

Now in our quotes dashboard we can see the quote link and copy the link for emailing. This page will also be linked to in our Quote emails when sent out to customers, so customers can view the quote in your store.

Sending a Customer Quote by Email

Customer quotes can be sent using the Quote API. The endpoint for this looks like:

POST /quote/{id|number}/send-quote

This sends an email to all customer email addresses attached to the quote. Email addresses sent to will include: 

  • Customer email by ID, matching the quote's customer_id .
  • Array of emails attatched to the quote, under the quote's customer_emails and defined when creating the quote.

The Email used is always the "shop:send-quote" email template.

Getting a list of Quotes in the Frontend

Requires:

  • Logged in customer
  • Quotes assigned to the logged in customer (using quote’s customer_id field)

Example:

{% for quote in customer.quotes %}
    <h2>{{ quote.name }}</h2>
    {% for item in quote.items %}
        <! -- Quote item details -- >
    {% endfor %}
{% endfor %}

Checking out a Quote in the Frontend

When a customer is looking at a quote in the frontend and wants to checkout and purchase that quote, they should do that by clicking a button that starts the process for them. To do that, this button requires a special handler, called "shop:onCreateOrderFromQuote". This readies the quote for checkout in the store.

Requires:

  • Ajax handler: shop:onCreateOrderFromQuote
  • Requires quoteId parameter

Example:

<h2>{{ quote.name }}</h2>
{{ open_form({'class': 'custom'}) }}
    <a href="#" class="button" 
        data-ajax-handler="shop:onCreateOrderFromQuote" 
        data-ajax-redirect="/cart"
    >Checkout this Quote</a>
    <input type="hidden" name="quoteId" value="{{ quote.id }}"/>
{{ close_form() }}