Skip to content

Kirby 6.0.0

Shop

Products for your sales

This set of blueprint samples is for a simple shop setup, with a shop overview page that lists all products in pagelist field and the single product pages with a cover image blueprint.

Shop overview

/site/blueprints/pages/shop.yml
title: Shop
icon: 🛍

options:
  status: false

fields:
  drafts:
    extends: fields/products
    label: Unpublished Products
    status: drafts
  listed:
    extends: fields/products
    label: Published Products
    status: listed
    layout: cards

Reusable products field

/site/blueprints/fields/products.yml
type: pagelist
label: Products
parent: site.find("shop")
template: product
info: "€ {{ page.price }} / {{ page.design }}"
image:
  src: page.image
  ratio: 1/1
  back: pattern

Result

Single product

/site/blueprints/pages/product.yml
title: Product
num: zero

status:
  draft: true
  listed: true

columns:
  main:
    width: 2/3
    fields:
      price:
        type: number
        step: 0.01
        before: €
      design:
        label: Design by …
        type: text
      sizes:
        type: checkboxes
        default:
          - S
          - M
          - L
          - XL
          - XXL
        options:
          - S
          - M
          - L
          - XL
          - XXL
      link:
        type: url
      description:
        type: textarea
  sidebar:
    width: 1/3
    fields:
      image:
        extends: fields/image
        template: cover
        min: 1
        image:
          ratio: 1/1

Reusable image field

/site/blueprints/fields/image.yml
type: filelist
label: Product Image
max: 1
layout: cards
info: "{{ file.dimensions }}"

Result

Shop template

/site/templates/shop.php
<?php snippet('header') ?>

<main>
  <?php snippet('intro') ?>

  <ul class="shop">
    <?php foreach ($page->children()->listed() as $product): ?>
    <li>
      <figure class="product">
        <a href="<?= $product->link() ?>">
          <?= $product->image()->crop(500) ?>
          <figcaption class="text">
            <h2 class="product-title"><?= $product->title() ?></h2>
            <p class="product-price">€ <?= $product->price() ?></p>
          </figcaption>
        </a>
      </figure>
    </li>
    <?php endforeach ?>
  </ul>
</main>

<?php snippet('footer') ?>