Merx

Add Products

A product is just a Kirby page with the product template.

Content

A product page must have a (net) price. 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: description

Add product to cart

Just add an array with a valid product page id.

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