Skip to main content

Reopen a Saved Configuration

This is step 3 of the lifecycle. When a visitor saves a configuration, they receive a PDF with a unique DIVA number (divaNr, e.g. DIVA-12345-1) and a link back to your website. Your website needs a configuration page behind this link that opens the Configurator with the saved configuration.

Required

Every integration needs a configuration page, even without a cart integration. Without it, the link in the PDF leads nowhere and visitors cannot continue their configuration. Tell Crystal Design the URL of this page, so that DIVA can put the correct link into the PDF.

The workflow​

  1. The trigger: the visitor clicks the link in their PDF, which leads to your configuration page.
  2. The handover: the widget on your configuration page reads the divaNr parameter from the URL.
  3. The restoration: the widget opens the Configurator with this divaNr.
info

The URL of the page is free to choose. The DIVA number is read from a divaNr parameter, for example:

  • yoursite.com/configurator?divaNr=DIVA-12345-1
  • yoursite.com/de/configurator?divaNr=DIVA-12345-1

If the DIVA number is part of the path instead, see Own URL formats.

The same page can be reused anywhere you want to reopen a configuration, e.g. for an "Edit" link on your cart page.

Step 1 – Add the Widget Element​

Place a diva-configurator-direct element on the configuration page, without a product, and load the widget script. The widget reads the divaNr from the URL of the page and opens the Configurator with the saved configuration right away. The spelling of the parameter does not matter: divaNr, divanr and DIVANR all work.

Visitors who open the page without a DIVA number, e.g. directly, see the content of the element. Put a form there, so they can enter the DIVA number from their PDF. Submitting the form reloads the page with ?divaNr=… and opens the configuration. No JavaScript is needed.

<div data-diva-widget-type="diva-configurator-direct">
<form method="get">
<input name="divaNr" placeholder="DIVA-12345-1" required />
<button type="submit">Open configuration</button>
</form>
</div>

<script src="https://<your-diva-api-host>/integration/api/widget/<YOUR_ORGANIZATION_ID>"></script>

When the visitor closes the Configurator, the form is shown again.

To add a reopened configuration to your cart, set data-diva-event-onaddtobasket on this element as well, see Add to Cart.

Language​

The Configurator opens in the language of the widget, see Language. Parameters in the URL of your page, such as &lang=fr, are not evaluated. If your configuration page serves several languages, set the lang attribute of the page (<html lang="fr">) or data-lang on the widget element to the language of the page. If the language only comes with the link, e.g. as &lang=fr, set data-lang from it with an inline script, in the same way as in Own URL formats.

Step 2 – Own URL Formats (optional)​

If the DIVA number is not in a divaNr parameter, e.g. because it is part of the path (/configuration/DIVA-12345-1), set it in data-diva-param-divanr with a short inline script. A data-diva-param-divanr on the element always takes precedence over the URL.

<div id="diva-configurator" data-diva-widget-type="diva-configurator-direct"></div>

<script>
// e.g. /configuration/DIVA-12345-1
const divaNr = location.pathname.split('/').pop();
if (divaNr.startsWith('DIVA-')) {
document.getElementById('diva-configurator').setAttribute('data-diva-param-divanr', divaNr);
}
</script>

<script src="https://<your-diva-api-host>/integration/api/widget/<YOUR_ORGANIZATION_ID>"></script>

The widget reads the attributes once, when the widget script runs. Place the inline script before the widget script and load the widget script without async or defer.

Complete Example​

Configuration page with input field – full HTML page
<!doctype html>
<html lang="en">
<head>
<title>Configuration</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div data-diva-widget-type="diva-configurator-direct">
<form method="get">
<input name="divaNr" placeholder="DIVA-12345-1" required />
<button type="submit">Open configuration</button>
</form>
</div>

<script src="https://<your-diva-api-host>/integration/api/widget/<YOUR_ORGANIZATION_ID>"></script>
</body>
</html>