Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This is an example plugin to add custom fields to your Shopware 6 newsletter subscription form. Used in conjunction with the Maileon plugin, the fields created can be submitted to Maileon as contact fields. The added fields are not stored in Shoprenter.

Installation

Attachments

The installation package can be downloaded here.

You can upload the package in the Shopware 6 admin interface as follows:

  • Go to Extensions → My extensions

  • Click to the Upload extension button

  • Select the installation package and open

  • After install, activate the plugin

Change fields

Go to the /custom/plugins/XQueueCustomForm/src/Resources/views/storefront/element/cms-element-form/form-types/newsletter-form.html.twig

Here you can add extra fields to the form:

Code Block
languagehtml
<div class="{{ formRowClass }}">
  {% block cms_form_newsletter_input_custom_field1 %}
      {% sw_include '@Storefront/storefront/element/cms-element-form/form-components/cms-element-form-input.html.twig'
          with {
          fieldName: 'customField1',
          type: 'text',
          additionalClass: 'col-12',
          label: 'Custom Field 1',
          placeholder: 'some custom field data'
      }
      %}
  {% endblock %}
</div>
  • fieldName: Here you have to enter the name of the field, this will be the identifier, it will not be visible on your frontend. This will also be the name of the custom contact field in Maileon. If no custom contact field with this name exists in Maileon, the Maileon Plugin will create it. In the settings of the Maileon plugin you have to enter this name, if there are more than one field the names have to be separated by semicolons (). Must not contain whitespaces!

  • type: Here you can specify the field type. You can set any type, but in Maileon the custom contact field type will be string!

  • label: The name of the field, this will appear on the frontend.

  • placeholder: To set the placeholder of the field.