Generate Cart Preview

Overview

The Generate Cart Preview endpoint returns product, pricing, and cart information without starting checkout. Use it to display product information on your website or generate localized pricing based on a customer's language or location.

📘

Note

This Generate Cart Preview endpoint does not create a purchasable cart. It returns product and pricing information that you can display on your own website.


Use case

Cloudify wants to display the latest pricing for its Cloudify Gold subscription on a marketing landing page without maintaining separate pricing information.

  1. The landing page calls the Generate Cart Preview endpoint.
  2. Cleverbridge returns localized product and pricing information based on the customer's language and location.
  3. The page displays the product information and allows the customer to increase the number of users.

When the customer selects Buy Now:

  • New customers are redirected to Cleverbridge checkout.
  • Existing customers can be processed using the ProcessCart endpoint before completing the purchase.

Implement the Generate Cart Preview endpoint

📘

Note

This endpoint returns preview data only. It does not create a shopping cart or initiate the checkout process.

⚠️

Important

Calling this endpoint frequently can generate significant server traffic. If you expect a high request volume, contact Client Experience before implementing your solution.

Before you start

Make sure that:

  • You have valid Basic authentication credentials.
  • You have the customer's IPv4 address to populate the RemoteAddress property.
  • You have the browser's Accept-Language value if you want to localize the preview.
  • The ShoppingCartUrl explicitly lists the product IDs that you want to preview.
  • You understand the supported and unsupported shopping cart URL formats described below.

Shopping cart URL limitations

The ShoppingCartUrl must explicitly contain the product IDs. URLs that resolve products dynamically are not fully supported.

Supported URLs

https://store.cleverbridge.com/677/?scope=checkout&cart=127957,127961,127960

Not supported URLs

Campaign URLs

https://store.cleverbridge.com/677/purl-buzzoffcleverbridge?scope=checkout

Campaign URLs resolve products dynamically and cannot be processed by this endpoint.

Protected URLs

The Generate Cart Preview endpoint cannot retrieve product information from protected URLs.

Product selection or recommendation URLs

https://store.cleverbridge.com/677/?scope=cart&cart=s3503

If you submit a product selection URL, only the default selected product is returned.

To retrieve all products, use a checkout URL that explicitly lists the product IDs.

Parameters

ParameterTypeRequiredExampleNotes
RemoteAddressstrYes4.2.2.2The IPv4-Address that corresponds with the country, state, etc. of the customer
ShoppingCartUrlstrYeshttps://www.cleverbridge.com/8/?scope=cart&cart=1455The URL you would use to redirect the customer to the checkout process.

Request

Call the Generate Cart Preview endpoint with the ShoppingCartUrl containing the products to preview.

The endpoint returns localized product and pricing information based on the supplied URL and the request parameters.

Example request

curl --location 'https://rest.cleverbridge.com/cart/generatecartpreview' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Basic YOUR_BASE64_ENCODED_CREDENTIALS' \
--data '{
  "RemoteAddress": "4.2.2.2",
  "ShoppingCartUrl": "https://www.cleverbridge.com/8/?scope=cart&cart=1455",
  "AcceptLanguage": "de; q=1.0, en; q=0.5",
  "GenerateSessionUrl": true
}'
import http.client
import json

conn = http.client.HTTPSConnection("rest.cleverbridge.com")
payload = json.dumps({
  "RemoteAddress": "4.2.2.2",
  "ShoppingCartUrl": "https://www.cleverbridge.com/8/?scope=cart&cart=1455",
  "AcceptLanguage": "de; q=1.0, en; q=0.5",
  "GenerateSessionUrl": True
})
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Basic YOUR_BASE64_ENCODED_CREDENTIALS',
}
conn.request("POST", "/cart/generatecartpreview", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'rest.cleverbridge.com',
  'path': '/cart/generatecartpreview',
  'headers': {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'Basic YOUR_BASE64_ENCODED_CREDENTIALS'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({
  "RemoteAddress": "4.2.2.2",
  "ShoppingCartUrl": "https://www.cleverbridge.com/8/?scope=cart&cart=1455",
  "AcceptLanguage": "de; q=1.0, en; q=0.5",
  "GenerateSessionUrl": true
});

req.write(postData);

req.end();
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://rest.cleverbridge.com/cart/generatecartpreview")
  .header("Content-Type", "application/json")
  .header("Accept", "application/json")
  .header("Authorization", "Basic YOUR_BASE64_ENCODED_CREDENTIALS")
  .body("{\n  \"RemoteAddress\": \"4.2.2.2\",\n  \"ShoppingCartUrl\": \"https://www.cleverbridge.com/8/?scope=cart&cart=1455\",\n  \"AcceptLanguage\": \"de; q=1.0, en; q=0.5\",\n  \"GenerateSessionUrl\": true\n}")
  .asString();

Response

The response contains the information required to render a product or shopping cart preview on your website.

{
    "Cart": {
        "CartItems": [
            {
                "Discount": null,
                "InternalProductId": "",
                "Name": "BlogMusic 2",
                "NameExtension": "",
                "ProductId": 1455,
                "Quantity": 1,
                "RunningNumber": 1,
                "SinglePrice": {
                    "Currency": "US Dollar",
                    "CurrencyId": "USD",
                    "Gross": 49.95,
                    "Net": 49.95,
                    "Vat": 0.0,
                    "VatPercentage": 0.0
                },
                "TotalPrice": {
                    "Currency": "US Dollar",
                    "CurrencyId": "USD",
                    "Gross": 49.95,
                    "Net": 49.95,
                    "Vat": 0.0,
                    "VatPercentage": 0.0
                }
            }
        ],
        "Currency": "US Dollar",
        "CurrencyId": "USD",
        "Language": "English",
        "LanguageId": "en",
        "TotalPrice": {
            "Currency": "US Dollar",
            "CurrencyId": "USD",
            "Gross": 49.95,
            "Net": 49.95,
            "Vat": 0.0,
            "VatPercentage": 0.0
        }
    },
    "SessionUrl": "https://www.cleverbridge.com/surl-YFCKBETQB3",
    "ResultMessage": "OK"
}

Depending on your configuration, the response can include:

  • Product information
  • Localized pricing
  • Currency
  • Tax information
  • Available quantities
  • Cart totals
  • Editable fields that can be presented to the customer

You can use this information to:

  • Display product and pricing information on a landing page.
  • Build a custom product comparison page.
  • Allow customers to modify supported values such as quantity before continuing to checkout.
  • Keep your website synchronized with product and pricing information stored in the Cleverbridge platform.

Did this page help you?