Emergency

In urgent situations or outages, you can send a text message to our emergency line

Emergency line (text message only)

+45 29 70 15 95

Send a text message with the following information:

  • Your name and webshop
  • A description of the problem

Note: This service is only for critical situations where your webshop is down or has serious problems. For regular support, please use our normal support channels.

Product recommendations in your own theme

How to add product recommendations to a theme that isn't one of Shoporama's own: either with a CSS selector from the admin, or with the Smarty tag in the template.

Reading time: about 8 minutes
Store owner Developer

Product recommendations are built into all of Shoporama's own themes, where you set them up as a module in the Page designer. If you've had a custom theme built, or heavily customized one of ours, you can still add recommendations to your own theme. There are two ways: one without code, and one for developers.

Without code: point to a spot on the page

Go to Design → Recommendations in your own theme. Here you fill in one line for each recommendation box you want to add, and save. You don't need to edit the theme's files.

The "Recommendations in your own theme" page in the Shoporama admin with fields for pages, CSS selector, position, type, quantity, and columns
Each line describes one recommendation box: where it should go, and what it should show.

The fields mean:

  • Pages: which pages the box should appear on. Choose "All pages", or limit it to, for example, only product pages or only the cart.
  • CSS selector: which element on the page the box should be placed relative to. It can be as simple as footer, or more specific, such as .product-page .description.
  • Position: whether the box should go before the element, after it, or inside it as the last content.
  • Type: which kind of recommendation. The same five as in the module.
  • Quantity and Columns: the maximum number of products shown, and how many appear side by side on large screens.
  • Heading: the text above the box. If you leave it blank, no heading is shown.

How to find the right selector

If you don't know what to enter in the selector field, right-click the spot in your store where the box should go, choose "Inspect", and see which class or tag the element has. It's better to start broad than narrow. footer with the position "Before" gives you a box at the bottom of the page, just above the footer, and it works with almost every theme.

If the element doesn't exist on a given page, nothing happens. The box removes itself instead of leaving a gap. That makes it safe to experiment.

With code: the Smarty tag

If you want to control the placement precisely in the template, you can use the tag directly:

<{recommendations type="also_viewed" product=$product limit=4 columns=4 title="Customers also viewed"}>

The parameters are:

  • type: also_viewed, also_bought, similar, popular, or recently_viewed
  • product: the product object on a product page. Leave it out on pages without one specific product
  • limit: the maximum number of products (default 4)
  • columns: columns on large screens (default 4)
  • title: the heading above the box

The tag outputs a placeholder and fetches the products themselves afterward. If you want to control how the cards look yourself, the theme can have its own components/reco-loop.html. If it exists, it's used. If it doesn't, we fall back to the theme's regular product card, and otherwise to a simple built-in layout.

How does it work under the hood?

Whichever of the two methods you use, the behavior is the same:

  • The page itself is delivered without recommendations, and the box is loaded afterward. This means the recommendations never delay the first rendering of the page, even if they are placed at the top.
  • Space for the box is reserved in advance with a gray skeleton the same size as the real cards, so the page doesn't jump when the content arrives.
  • No external files are loaded. All the code is inline and takes up about 5 KB in total.
  • The response is cached for one hour. So two visitors on the same product page within the same hour cost only one database lookup.
  • The "Most Recently Viewed" list is stored in the browser's localStorage on the customer's own device and is only sent along when that particular type needs to be shown.

Frequently asked questions

What happens if JavaScript fails, or the selector isn't found?

Then the box removes itself, and the theme's own section wrapper is also cleared away if it's left empty. So you get neither an empty gap nor a blank strip. Each box is handled separately, so an error in one box doesn't stop the others on the page.

I take a product offline in the middle of the day. Can it still be shown?

Yes, for up to an hour. Recommendation responses are cached for one hour, so a box that has already been calculated may show the product until the cache expires. If the customer clicks it, they go to the product page, which handles the fact that the product isn't available. If the change needs to take effect immediately, you can clear your store's cache.

How big is it, and what does it cost in speed?

About 5 KB of inline code, no external files, and no blocking requests. Tracking is sent with navigator.sendBeacon, which is asynchronous and never waits for a response. On a store without recommendations set up, nothing is output.

Can I have several boxes on the same page?

Yes. Both the selector method and the tag can be used several times on the same page. The selector method allows up to ten lines in total.

Does it work with page caching?

Yes. What is delivered with the page is the same placeholder for all visitors, and everything visitor-specific is loaded afterward. That's why pages with recommendations can be cached statically exactly as before.

Can I style the box myself?

Yes. The box has the classes sr-reco, sr-reco-head, sr-reco-title, and sr-reco-body, which you can style in your own stylesheet. You can adjust the height of the reserved space with the CSS variables --sr-reco-img and --sr-reco-text if your product cards are taller or shorter than the default.

See also Recommendations: automatically show the products your customers are looking for and How to read the statistics for recommendations.