Prefabs

Building your shop frontend with PHP

The localhost demo works out of the box. To build a custom frontend for your shop, copy a few snippets and templates from the plugin into your root Kirby project folders. As long as you keep the folders and filenames unchanged, Kirby will treat your files as replacements for those from the Kirby Kart plugin.

The plugin includes a hardcoded yet stylable theme as an alternative to creating your own PHP-based frontend.

Content

  • Create a content file for the cart at content/cart/cart.txt

Snippets

The Kirby Kart plugin includes several preinstalled snippets. These snippets are used in the localhost demo and serve as starting points for you.

When you create a snippet in your site/snippets-folder with the same name as the one from the plugin you will be overwriting it. My advice would be to copy the snippets from the plugin to your site/snippets-folder one by one as you proceed to customize the look. Copying everything at once can result in an overwhelming number of new snippets, many of which may not be necessary for your setup and can be left out.

Most likely you will want to copy at least these five snippets:

  • snippets/kart/cart.php
  • snippets/kart/cart-add.php
  • snippets/kart/cart-buy.php
  • snippets/kart/wish-or-forget.php
  • snippets/kart/wishlist.php

Templates

Similarly to the snippets, the Kirby Kart plugin registers a few templates used in the localhost demo, and again, you might not need all of them. Start by copying these four into your site/templates folder.

  • templates/cart.php
  • templates/order.php
  • templates/products.php
  • templates/product.php

Blueprints

The plugin automatically registers the blueprints it needs and provides a simple way to add custom product fields.

Create a site/blueprints/tabs/products-local.yml, and any columns/sections/fields you add there will be shown on the second tab of the product's blueprint. This allows me to push improvements to the blueprints without disrupting your custom setup.

The alternative would be to copy all the YAML files from the plugin blueprints-kart into your project's site/blueprints/pages and site/blueprints/users-folders. While this option allows full adjustment of the panel views, you will miss out on my updates.

If you customize the customer blueprint or add additional roles make sure these roles do not have access to the panel!

Models

The plugin automatically registers the necessary models, and to keep the complexity of the codebase manageable, you cannot currently add code to them directly. One way to extend the models would be to extend the classes from Kart and register your models after Kirby has loaded Kart (mind the extensions/plugin loading order).

If you need to add a few functionalities to the models quickly, consider using Page Method extensions instead.

Providers

You can extend the classes of a provider and re-register them, like with the models. The documentation of the default provider, the kirby_cms-provider, explains how to do so.

Kirby Kart is not affiliated with the developers of Kirby CMS. We are merely standing on the shoulder of giants.
© 2025 Bruno Meilick All rights reserved.