Commerce block layouts
A drop-in component’s layout is defined by an HTML fragment that controls where the drop-in’s containers appear on the page. You can customize the layout as you would with any HTML, by using CSS and adding, removing, or rearranging the elements in the HTML. In this topic, we’ll customize the product details layout by adding the Product Recommendations block.
Big Picture
This screenshot shows the product details page with the Product Recommendations block below the product gallery container.
Customize commerce block layouts
For this use case, we’ll customize the product details layout by adding the Product Recommendations block inside the product details block, instead of below it.
Add an Edge Delivery block to a commerce page
For example, add a Product Recommendations block to the product details page so that it can be rendered on the page, then referenced and moved to the layout (in code):
Add an element to the layout and reference it
Add an HTML element to the commerce block’s layout where you want the Edge Delivery block (or other content) to appear. In this example, we want the Product Recommendations block to appear in the left column of the product-details layout, below the product gallery. So we add a div
element to the left column with a class of product-details__prex
.
Then, we reference the div
element in the layout as follows:
Move the Edge Delivery block to the layout
Within the eds/lcp
lifecycle event, query the Edge Delivery block’s class selector from the rendered block and append it to right element in the layout. In this example, we select the Product Recommendations block using the .product-recommendations
class, then move it to the element you want in the layout ($prex
).