You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This tutorial explains how you can pass the product configuration to a contact form when the "request product" button is clicked.
This tutorial explains how you can pass the product or plan configuration to a contact form when the "request product"/"request plan" button is clicked.
For this tutorial we will use the [Uniform plugin](https://github.com/mzur/kirby-uniform) by Martin Zurowietz. If you already use a different plugin or prefer to use Kirby's core methods, you can adapt the code accordingly. If you want to follow the example, please first install the Uniform plugin as [explained in its docs](https://kirby-uniform.readthedocs.io/).
<?php foreach ($configuration->parts() as $part): ?>
<?php foreach ($item->parts() as $part): ?>
<tr>
<td><?= esc($part->count()) ?></td>
<td><?= esc($part->articleNr()) ?></td>
Expand All
@@ -120,6 +127,7 @@ Success!
</tr>
<?php endforeach ?>
</table>
<?php endforeach ?>
<?php endif ?>
<style>
Expand All
@@ -143,7 +151,7 @@ For a more user-friendly output, we need a custom email template in `site/templa
-------------------
Configuration data:
<?= roomleConfiguration($configuration) ?>
<?= roomlePlan($configuration) ?>
<?php endif ?>
```
Expand All
@@ -153,7 +161,7 @@ This email template is already referenced in the controller from step 1.
## 4. Point the plugin to the contact form
Now you need to tell the Roomle plugin that it should submit the configuration data to your contact form whenever the "request product" button is clicked.
Now you need to tell the Roomle plugin that it should submit the configuration data to your contact form whenever the "request product"/"request plan" button is clicked.
You can either do this by selecting the contact form page in the block settings or by setting a global default in `site/config/config.php`:
Expand All
@@ -171,11 +179,11 @@ return [
### More fields in the page template
The `$configuration` object and its children also have more fields and methods you can use for output on the form page (e.g. the part price). To see what is possible, please take a look at the [plugin classes](https://github.com/lukasbestle/kirby-roomle/tree/main/src/classes), particularly `Configuration`, `Parameter`and `Part`.
The `$plan` object and its children also have more fields and methods you can use for output on the form page (e.g. the part price). To see what is possible, please take a look at the [plugin classes](https://github.com/lukasbestle/kirby-roomle/tree/main/src/classes), particularly `Configuration`, `Parameter`, `Part`and `Plan`.
### Custom configuration rendering in the email
The email template from step 3 prints the whole `$configuration` object. Internally, this will render three snippets: `roomle/configuration.php`, `roomle/part.php` and `roomle/parameter.php`.
The email template from step 3 prints the whole `$plan` object. Internally, this will render four snippets:`roomle/plan.php`,`roomle/configuration.php`, `roomle/part.php` and `roomle/parameter.php`.
If you want to customize the rendering in the email, you have two options: