Skip to main content

Gift Card Designer

With the gift card designer you build the PDF of your gift cards in the Administration, with drag and drop. Add titles, text, images, rectangles and a QR code, and show the recipient, the message, the code or the amount with the variables button.

Open the designer in Content > Gift card designs.

Create a design​

  1. Go to Content > Gift card designs and click Create.
  2. Enter a Design title and save.
  3. Add layers and arrange them on the page (see below).
  4. Click Save, or Save & preview PDF to see the real PDF.
  5. Select the design as Template in the Gift card tab of your gift card products. See Gift card design.

In the list of designs, the context menu of a design has Duplicate and Preview PDF.

Design configuration​

Technical name
A name for yourself, e.g. to tell designs apart.

Background color
The color of the whole page.

Document size
A4 portrait (default) or A4 landscape.

Layers​

A design is built from layers. Add a layer with the buttons in the toolbar, then drag it to its place and resize it with its handles on the canvas. The sidebar lists all layers: select a layer there or on the canvas to change its settings. The toolbox of a selected layer moves it up or down (layers on top cover the ones below), deselects it or deletes it.

Every layer has a Size (width and height) and a Position (horizontal and vertical, from the chosen Anchor corner).

Title layer​

Plain text with its own typography, for headings, names and amounts.

  • Text: plain text without formatting. Line breaks are kept, and the text never wraps.
  • Font:
    • Base font of the gift card.
    • Google Font: search any font of fonts.google.com. Only the weights and styles the font has can be chosen. The font is downloaded from Google when the PDF is generated and embedded in the PDF.
    • Custom font: a font the PDF renderer knows: Helvetica, Times, Courier, DejaVu Sans, DejaVu Serif or DejaVu Sans Mono.
  • Font size: you can also drag the handles of the layer to scale the text.
  • Font weight, Italic, Color (empty is black), Line height, Letter spacing.
  • Alignment: left, center or right.
  • Capitalization: as typed, UPPERCASE, lowercase or Capitalize Words.
tip

Because titles never wrap, a long personal message runs off the card. Use a text layer for the message.

Text layer​

Rich text from Shopware's text editor. Click Edit content to open the editor. Set the Horizontal alignment (left, center, right) and Vertical alignment (top, center, bottom) of the text block within the layer. Text wraps within the width of the layer.

Image layer​

An image from the Media library, e.g. your logo or a photo, with an Alt text and a Title.

Rectangle layer​

A colored area. Set its Color and the Border radius of each corner.

QR code layer​

The code of the gift card as a QR code. It has no settings besides its size and position.

Variables​

The Insert variable button shows the gift card data on the card. It is in the settings of title layers and in the toolbar of the text editor. Choose a variable and its Twig code is inserted at the cursor, and Render as Twig code is switched on.

{# Personalisation #}
{{ giftcard.payload.recipientName ?? '' }} {# Recipient name (to) #}
{{ giftcard.payload.senderName ?? '' }} {# Sender name (from) #}
{{ giftcard.payload.message ?? '' }} {# Personal message, in a title layer #}
{{ (giftcard.payload.message ?? '')|nl2br }} {# Personal message, in a text layer #}

{# Gift card #}
{{ giftcard.code }} {# Code #}
{{ giftcard.initialAmount|currency }} {# Amount #}
{{ giftcard.balance|currency }} {# Balance #}
{{ giftcard.validUntil ? giftcard.validUntil|date('d/m/Y') : '' }} {# Valid until #}
{{ giftcard.name }} {# Name #}

The personalisation fields are only filled when the buyer entered them. See personalisation.

The canvas shows these variables with sample values (e.g. "Alex", "Sam", "Happy birthday!"), so you can see how much room they take.

Translations​

Switch the content language at the top of the designer to translate the texts and titles of a design. In another language than the system language, only the language-specific options can be changed, such as the content of text and title layers. The PDF is generated in the language of the order.

PDF preview​

The browser and the PDF renderer of Shopware draw some things a little differently. Use Save & preview PDF (in the arrow menu of the Save button) to see the real PDF, with a demo gift card.

Twig code​

Title and text layers with Render as Twig code switched on are rendered as Twig. Besides the variables above, you can write your own Twig code.

Available Twig variables​

VariableContents
giftcardThe gift card (Laenen\Giftcard\Content\Giftcard\GiftcardEntity)
giftcard.extensions.originOrderThe order in which the gift card was bought (OrderEntity), if there is one
configThe gift card settings of the product (ProductGiftcardEntity)
contextThe SalesChannelContext
designThe design (GiftcardDesignEntity)
templateConfigAn array with e.g. logo, the PDF Logo of the plugin configuration

Examples​

Code in groups of four​

{% apply spaceless %}
{% for char in giftcard.code|split('') %}
{{ char }}
{% if loop.index % 4 == 0 %} {% endif %}
{% endfor %}
{% endapply %}

Creation date​

{{ giftcard.createdAt|date('d/m/Y') }}

Order number​

{{ giftcard.extensions.originOrder.orderNumber ?? '' }}

Message only when there is one​

{% if giftcard.payload.message ?? false %}
{{ giftcard.payload.message|nl2br }}
{% endif %}

To add your own data, see Developers.