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.

Smarty template variables in Shoporama themes

Overview of the global and page-specific Smarty variables available in Shoporama themes, such as the cart, customer, campaigns, products, and categories.

Reading time: about 13 minutes
Developer

There are broadly two types of variables in Shoporama themes: global variables, which are available on every page, and variables that are only available on certain pages. Global variables include things like the contents of the cart, while the others are, for example, the landing page or the product being shown. Below is a list of the variables that are available when templates are rendered on the web, that is, not in emails.

If a variable contains an object, you can see the object's methods in our overview of the template API.

In general, we also recommend taking a look at our Alaska theme, which you can download for free and which contains examples of how the variables below work.

The Shoporama code editor with the file list for the MBN-Delaware theme's template files and the code from after_purchase.html open for editing.
The code editor under Design, where you edit the theme's template files. The file list on the left shows all of the theme's files, and the editor on the right shows and edits the code in the selected file.

Global variables

$webshop, the store being shown.

$webshop->getNewsletters($limit, $offset, $count, $sort), the store's publicly shared newsletters, for building an archive. Each item is a SafeNewsletterCampaign with methods such as getTitle(), getDate(), getExcerpt(), getImage(), getUrl(), and getContent(). Use $webshop->getLatestNewsletter() for the most recent newsletter and $webshop->hasNewsletters() to check whether there are any. Requires the public newsletter archive to be turned on under Newsletter.

$inc, the type of page being rendered. Its value can be also, search, basket, address, shipping, approve, payment, thanks, order, product_review, subscription, blog, user-sign-up, user-sign-in, user-sign-out, user-edit, user-reset-password, user-profile, user-orders, user-subscriptions, user-change-card.

$shipping, the selected shipping method.

$frontpage, if a static page has been chosen as the front page.

$pager_array, if the page being shown has pagination. It contains max, current, total, url, first_url.

$pager, the pager object.

$current_url, the absolute URL of the page being shown.

$top_url, the current relative URL.

$get, $post, $cookie. Arrays containing the GET, POST, and COOKIE values, respectively.

The system sets the following GET parameters automatically:

  • payment_cancelled — set to 1 when a customer cancels or fails in the payment flow. Use $get.payment_cancelled to show an error message in your theme.

$user_id, the user ID if the customer is logged in.

$customer, the customer, if they are logged in.

$remote_addr, the customer's IP address.

$selected_payment_gateway, the ID of the selected payment gateway.

$join_mailinglist, whether the customer has chosen to sign up for the newsletter.

$basket_url, the URL of the cart and its contents.

$campaign_ids, the IDs of campaigns if the products in the cart match a campaign.

$campaigns, if there are active campaigns.

$campaign_discount, the discount from the active campaigns.

$campaign_matches, an array of products that match a campaign. If there are no products, the variable is null.

$unpaid_order, if the customer has an unpaid order (from a closed cart).

$unpaid_recurring_order, an unpaid subscription.

$basket, the contents of the cart as an array, where each element is a product in the cart, with these values:

id, a unique ID for the line

product_id, the ID of the product

in_stock, true/false depending on whether the product is in stock

product, the product

attributes, the product's attributes

own_id, the SKU

amount, the quantity in the cart

comment, a comment, if any

bundle, an array of the products if the product is a bundle

$subscriptions, the subscriptions in the cart.

$price, the subtotal of the cart contents.

$shipping_price, the shipping price.

$total_price, the total price of the cart contents.

$vat, the VAT on the cart contents.

$basket_weight, the total weight of the cart (for shipping, for example).

$total_amount, the total number of products in the cart.

$voucher, the discount code, if there is one.

$voucher_discount, the discount from the discount code.

$shipping_country, the selected delivery country.

$nofollow, true/false depending on whether nofollow is set on the page.

$meta_title, the title of the page.

$meta_description, the description of the page.

$canonical, the canonical URL.

$session_order, an array with the billing address.

$session_del, an array with the delivery address.

$session_extra, an array with extra fields on the order. If a field is posted as extra[test]=123, $session_extra.test will be 123, and it is saved on the order.

Variables by page type

You are free to name the files in a Shoporama theme as you like. However, some files are required. For example, there must be a global.html, which is responsible for rendering all the other files. The actual content of the page is in $contents, and that content comes from index.html. If you do not use our Theme Builder, index.html will typically need to check which type of page is being shown and then show the content. For example:

<{if $product}>
 <{include file="product.html" product=$product}>
<{/if}>

product.html then handles showing the product. A classic setup looks like this:

<{if $inc}>
 <{include file=$inc}>
<{elseif $category}>
 <{if $category->isFront()}>
 <{include file="front.html" category=$category}>
 <{else}>
 <{include file="category.html" category=$category}>
 <{/if}>
<{elseif $landing_page}>
 <{include file="landing_page.html" landing_page=$landing_page}>
<{elseif $product}>
 <{include file="product.html" product=$product}>
<{elseif $page}>
 <{include file="page.html" product=$page}>
<{elseif $blog_post}>
 <{include file="blog_post.html" product=$blog_post}>
<{/if}>

Note that $inc is a bit special, because it is the variable that renders basket.html, for example, when the customer is in the cart.

If you use the Theme Builder, the theme must first of all be written in Bootstrap. It must also include an extra file called default_contents.html, which has the same content that index.html had before. index.html must now contain the following:

<{if $tb_contents}>
 <{$tb_contents}>
<{else}>
 <{include file="default_contents.html"}>
<{/if}>

Here, $tb_contents is the content from the Theme Builder.

Shipping

$shops, the available parcel shops.

$shipping_module, the name of the shipping module. For example gls.

$xml_url, the URL for parcel shop lookups, if available.

$no_shops, true/false depending on whether there are parcel shops available.

$bird_delivery, true/false. Whether Burd delivery is available at the selected delivery address.

Address

No variables beyond the global ones.

Approve

No variables beyond the global ones.

Also

$product, the product that was just added to the cart.

Blog

$blog_posts, an array of blog posts.

Blog post

$blog_post, the blog post being shown.

Category

$category, the category being shown.

$products, an array of products.

Front

$category, the category.

Landing page

$landing_page, the landing page being shown.

$meta, an array of extra fields

$products, an array of products.

Page

$page, the static page being shown.

Product

$product, the product being shown.

$meta, an array of extra fields

Order

$order, the order.

Product review

$order, the order being reviewed.

Search

$products, an array of products.

$landing_pages, an array of landing pages.

$categories, an array of categories.

$count, the number of results.