Product Detail Page
On a product detail page (PDP), DIVA can show the media of a product directly on your page, typically in the image column. This is optional and can be combined with a "Configure" button that starts a new configuration.
The widget displays the product as a media gallery:
- Images with zoom, a fullscreen view and thumbnails to switch between them
- 3D model of the product, if one is available
- AR button, if the product has a 3D model: visitors scan a QR code and view the product in their own room with their smartphone
Visitors can swipe through the media on touch devices. Product texts, prices and the "Add to cart" button stay part of your own page.
Step 1 – Add the Widget Element
Place an element on the page where the product media should appear. Set data-diva-widget-type to diva-product-detail-page and tell the widget which product to show.
Replace <PRODUCT_ID> with the ID of the product that should be shown.
<div data-diva-widget-type="diva-product-detail-page" data-diva-param-productid="<PRODUCT_ID>"></div>
The widget replaces the content of the element, so the element can stay empty.
Identify the product
Instead of the DIVA product ID, you can also pass the DIVA number or your own article number. Set exactly one of these attributes:
| Attribute | Identifies the product by |
|---|---|
data-diva-param-productid | the DIVA product ID |
data-diva-param-divanr | the DIVA number |
data-diva-param-articlenr | your own article number. This requires that Crystal Design has set up the article number field for your organization |
If more than one is set, the product ID wins over the DIVA number, and the DIVA number wins over the article number.
Size
The widget fills the width of its element. If the element has a height, the widget uses it; otherwise the widget is as high as it is wide (square). Control the size with your own CSS on the element.
Language
The widget texts (buttons, AR hint, error message) are available in German, French, Italian and English. The widget uses the language set in data-lang. Without it, the widget uses the lang parameter of the widget script URL, then the lang attribute of your page (<html lang="fr">), then the language of the visitor's browser and finally German. See Language for details.
<div data-diva-widget-type="diva-product-detail-page" data-diva-param-productid="<PRODUCT_ID>" data-lang="en"></div>
Step 2 – Load the Widget Script
Include the widget script before the closing </body> tag, after the element from Step 1. If you also use the Configurator widget on the same page, include the script only once. It loads all widgets on the page.
Replace <YOUR_ORGANIZATION_ID> with your organization ID.
<script src="https://<your-diva-api-host>/integration/api/widget/<YOUR_ORGANIZATION_ID>"></script>
That's it. The product media now appear in the element.
Products vary from page to page, so as a Best Practice this should be managed dynamically. Link the data-diva-param-productid (or data-diva-param-articlenr) value to a user-accessible field within your CMS (like WordPress), or fill it from the product your shop system is rendering.
Complete Example
The example shows a product detail page with the product media on the left and the product information together with a Configurator button on the right.
Product detail page – full HTML page
<!doctype html>
<html lang="en">
<head>
<title>Product Detail Page Widget</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
.product {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 2rem;
max-width: 1200px;
margin: 0 auto;
padding: 1rem;
}
@media (max-width: 768px) {
.product {
grid-template-columns: 1fr;
}
}
#configure-btn {
display: inline-block;
padding: 0.75rem 1.5rem;
background-color: #713434;
color: #fff;
border-radius: 4px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="product">
<div data-diva-widget-type="diva-product-detail-page" data-diva-param-productid="<PRODUCT_ID>"></div>
<div>
<h1>Product name</h1>
<p>Product description from your shop.</p>
<div id="configure-btn" data-diva-widget-type="diva-configurator-button" data-diva-param-productid="<PRODUCT_ID>">
Configure product
</div>
</div>
</div>
<script src="https://<your-diva-api-host>/integration/api/widget/<YOUR_ORGANIZATION_ID>"></script>
</body>
</html>
Attributes
| Attribute | Example | Description | Required |
|---|---|---|---|
data-diva-widget-type | diva-product-detail-page | Selects the widget. Always diva-product-detail-page | yes |
data-diva-param-productid | Q7vdOYy4g7y5cL4TVWaIt | The DIVA product ID of the product to show. The product must be stored in DIVA and be available in your organization | one of the three |
data-diva-param-divanr | 123456 | The DIVA number of the product to show, as an alternative to the product ID | one of the three |
data-diva-param-articlenr | ART-4711 | Your own article number of the product to show, as an alternative to the product ID. Requires the article number field to be set up for your organization | one of the three |
data-lang | en | Language of the widget texts: de, fr, it or en. See Language for the fallback order | no |