Skip to main content
The product page displays detailed information about a single product, including images, pricing, options, and purchase controls.

Template location

src/views/pages/product/single.twig

Page structure

The product page consists of several main sections:
  • Product image gallery with slider
  • Product details (name, price, description)
  • Product options and variations
  • Add to cart functionality
  • Product ratings and reviews
  • Related products

Key variables

Product object

VariableTypeDescription
product.idintProduct ID
product.namestringProduct name
product.descriptionstringProduct description (HTML)
product.urlstringProduct URL
product.typestringProduct type: product, service, group_products, codes, digital, food, donating
product.statusstringProduct status: sale, out, out-and-notify
product.skustringProduct SKU
product.pricefloatCurrent price
product.sale_pricefloatSale price if on sale
product.regular_pricefloatRegular price
product.starting_pricefloatStarting price for products with options
product.currencystringCurrency code

Product media

VariableTypeDescription
product.image.urlstringMain product image URL
product.image.altstringImage alt text
product.imagesarrayArray of all product images
product.images[].idintImage ID
product.images[].urlstringImage URL
product.images[].altstringImage alt text
product.images[].video_urlstringVideo URL if image is a video
product.images[].typestringMedia type: image or video

Product pricing

VariableTypeDescription
product.is_on_saleboolWhether product has discounted price
product.discount_percentagestringDiscount percentage (e.g., “20%“)
product.is_taxableboolWhether tax is included in price
product.discount_endsdateDiscount end date

Product inventory

VariableTypeDescription
product.quantityintAvailable quantity (null if unlimited)
product.sold_quantityintNumber of units sold
product.max_quantityintMaximum quantity per order
product.is_availableboolWhether product is available
product.is_out_of_stockboolWhether product is out of stock
product.is_hidden_quantityboolWhether quantity is hidden
product.can_show_remained_quantityboolWhether to show remaining quantity
product.can_show_soldboolWhether to show sold count

Product features

VariableTypeDescription
product.has_optionsboolWhether product has options
product.has_metadataboolWhether product has metadata
product.has_custom_formboolWhether product has custom form
product.can_add_noteboolWhether customer can add notes
product.can_upload_fileboolWhether customer can upload files
product.is_giftableboolWhether product can be gifted
product.is_require_shippingboolWhether product requires shipping
product.has_3d_imageboolWhether product has 3D image
product.has_size_guideboolWhether product has size guide

Code examples

Display product price

<div class="product-price">
  {% if product.is_on_sale %}
    <span class="sale-price">{{ product.sale_price|money }}</span>
    <span class="regular-price">{{ product.regular_price|money }}</span>
  {% else %}
    <span class="price">{{ product.price|money }}</span>
  {% endif %}
</div>

Display product images

<salla-slider id="details-slider-{{ product.id }}" type="thumbs">
  <div slot="items">
    {% for image in product.images %}
      <a href="{{ image.url }}">
        <img src="{{ image.url }}" alt="{{ image.alt }}">
      </a>
    {% endfor %}
  </div>
</salla-slider>

Display product rating

{% if product.rating %}
  <salla-rating-stars 
    value="{{ product.rating.stars }}"
    reviews="{{ product.rating.count }}">
  </salla-rating-stars>
{% endif %}

Add to cart form

<form class="product-form" 
      onsubmit="return salla.form.onSubmit('cart.addItem', event)">
  <input type="hidden" name="id" value="{{ product.id }}">
  
  {% include 'pages.partials.product.options' %}
  
  <salla-quantity-input 
    max="{{ product.max_quantity }}" 
    value="1" 
    name="quantity">
  </salla-quantity-input>
  
  <salla-add-product-button
    product-id="{{ product.id }}"
    product-type="{{ product.type }}"
    product-status="{{ product.status }}"
    type="submit">
    {{ product.add_to_cart_label }}
  </salla-add-product-button>
</form>

Special features

Donation products

For donation type products:
{% if product.donation %}
  <div class="donation-info">
    <p>Collected: {{ product.donation.collected_amount|money }}</p>
    <p>Target: {{ product.donation.target_amount|money }}</p>
    <p>Progress: {{ product.donation.target_percent }}%</p>
  </div>
{% endif %}

Notify when available

{% if product.notify_availability %}
  <salla-add-product-button
    {{ product.notify_availability.subscribed ? 'is-subscribed' : '' }}
    channels="{{ product.notify_availability.channels|join(',') }}">
  </salla-add-product-button>
{% endif %}
Product options are included via {% include 'pages.partials.product.options' %} which handles complex option types like colors, sizes, and custom fields.

Build docs developers (and LLMs) love