Merx

Add Products

A product is a Kirby page with a product template.

Content

A product page must have a price (including tax). Everything else is optional. The tax is a percentage float.

content/nice-shoes/product.txt

Title: Nice shoes
----
Price: 99.99
----
Tax: 19
----
Description: Lorem Ipsum

Blueprint

Merx comes with a default product blueprint. You can extend or overwrite the blueprint with your own fields.

site/blueprints/product.yml

title: Product
fields:
  price:
    label: Price
    type: number
    required: true
    min: 100
  description:
    label: Description
    type: textarea

Add product to cart

Add an array with a valid product page id. The page must have a price field.

$cart = merx()->cart();
$cart->add([
  'id' => 'nice-shoes',
]);
$cart->getSum(); // 99.99
$cart->getTax(); // 15.964789916