Pricing API

You are reading about requirements for the integration done by the Luigi's Box team. You can safely skip this part of the documentation if you are integrating yourself using either API or Luigi's Box frontend libraries.

The pricing API is used mostly in B2B store for the complex scenarios where you are using a pricing model where the same product can have different price for different customers. Note that if you have relatively small number (less than 20) of pricing levels, we can use a simpler solution than the pricing API. The pricing API is usually used for cases where there are infinite numbers of pricing combinations and they are impossible to enumerate.

Luigi's Box can use a pricing API to load prices for the specific products for the currently logged in customer.

The pricing API has to be implemented by you and respect the specification in this document.

Specification

GET /api/pricing?products=2342,2343,4525

We will call the API passing it the comma delimited list of products along with all of the user cookies. You are supposed to use the cookies to identify the user and respond back with the structured data about per product pricing. If the product is discounted, you may also include price_old attribute to denote theoriginal price. The expected response is noted below.

{
  2342: {
    price: "34 EUR",
    price_old: "37 EUR"
  },
  2343: {
    price: "18 EUR",
    price_old: "22 EUR"
  },
  4525: {
    price: "13.90 EUR"
  }
}

The flow of the API call is as follows:

  • Your end-user types into the searchbox
  • Our integration code calls the respective service API (autocomplete, search, recommender, etc.) and loads the results
  • Results are rendered without prices, instead of prices, we show just loading indicator
  • We call your pricing API, passing in the product IDs and wait for your API to respond
  • While the API call is in-flight, the loading indicator is shown instead of prices. The latency of your API impacts the perceived loading speed.
  • Once your pricing API responds, we replace the loading indicators with the prices returned by the API

CORS

If you are providing us with an API endpoint, and that API lives on another domain or a subdomain than the main website, then you will need to provide CORS headers. The request to your API will be done with withCredentials: true, in order to allow the browser to send cookies which allow you to identify the user. Using withCredentials: true in the request has an impact on the CORS headers that you need to set.

These are the response HTTP headers that you need to set. Please replace https://www.yourstore.com in the example with your domain.

Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: https://www.yourstore.com
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Access-Control-Allow-Headers: *

Note that you can't simply set Access-Control-Allow-Origin: * because the wildcard mode is not compatible with the credentials mode.