--- title: "Tutorial: Creating templates" slug: "tutorial-creating-templates" tags: ["template", "documents", "receipts", "internationalization", "selling experience", "Associate App", "omnichannel manager ", "fiscalization", "sales", "configuration"] updated: 2026-10-22T09:19:42Z published: 2026-10-22T09:19:42Z canonical: "docs.newstore.com/tutorial-creating-templates" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.newstore.com/llms.txt > Use this file to discover all available pages before exploring further. # Tutorial: Creating templates In this tutorial, we will create a new Sales receipt template to help familiarize you with the way templates work at NewStore. > [!NOTE] > Important > > - We assume that you are familiar with [jinja2](http://jinja.pocoo.org/docs/2.10/). > - NewStore only supports templates that are less than 1 MB in size. Documents exceeding this size are not generated. We also assume in this tutorial that as a retailer, you operate in a country where Fiscal regulations apply, so you need a Fiscal signature to be printed in the receipts. For a guide on creating a fiscal signature template, see [this section](/v1/docs/tutorial-creating-templates#creating-a-fiscal-signature-template) of the tutorial. > [!NOTE] > Important > > We assume that you have an authentication token stored in the `AUTH_TOKEN` variable. Retrieve one with the following call: > > ```plaintext > export AUTH_TOKEN=$(curl -s /v0/token -d \ > "grant_type=password&username=&password=" | jq -r.access_token) > ``` ## Using the API Let's create a sales receipt using the methods under the `/templates`[resource](/developers/tutorials/api/integration/nom/nom_platform_templates_api): ```plaintext https://{retailer}.{stage}.newstore.net/{version}/d/templates/ ``` All the methods are authenticated and managed in an [OAuth 2.0](https://oauth.net/2/) compliant way. See [Getting started with NewStore APIs](/v1/docs/getting-started-with-newstore-apis#api-start) for more information. ## Preparing to create a sales receipt template Before we begin, let's create or gather all the information we might need during this process: - A folder to contain the template for each locale required by the retailer. - The design specifications and size requirements for the template. For example, knowing whether the document being generated from the template uses a receipt printer, document printer or a thermal printer might influence the size and design of the template. - Common assets that we want to reuse across templates to reinforce the retailer's branding guidelines. For example, the logo, social media icons, address and contact information, etc. When we're ready, let's create a sales receipt template. > [!NOTE] > Important > > Receipts created within non-production environments should be marked with an indicator, such as a header text or watermark. The indicator must state that the receipt is not valid and is for testing purposes only. The indicator helps retailers to identify a test receipt and prevents unintended usage of such receipts. ### Getting the available templates Let's retrieve the list of available templates and their identifier by using the [list template method](/developers/tutorials/api/integration/nom/nom_platform_templates_api#operation/List%20templates): ```plaintext curl -H "Authorization: Bearer $AUTH_TOKEN" -X GET "https:///v0/d/templates/templates" ``` The response contains all the template identifiers: ```json {  "data":[    {      "id":"in_store_pickup_ready_email_subject"    },    {      "id":"in_store_pickup_ready_email"    },    {      "id":"sales_receipt"    },    {      "id":"invoice"    },    {      "id":"shipment_label"    }  ] } ``` The `sales_receipt` template is the one we have to use. ### Retrieving the sales receipt template Let's retrieve the sales receipt template in the *en_US* locale with the [get template method](/developers/tutorials/api/integration/nom/nom_platform_templates_api#operation/Get%20template): ```plaintext curl -H "Authorization: Bearer $AUTH_TOKEN" -X GET "https:///v0/d/templates/templates/sales_receipt/localization/en_US" ``` The response contains the template itself: ```plaintext {%- set decimal_separator = decimal_separator | default('.') -%} {%- set num_items_on_one_page = num_items_on_one_page | default(6) -%} {%- macro currency(amount) -%} {% set split = format_currency(amount).split(decimal_separator, 1) %} {{ currency_symbol(currency_code) }}{{ split[0] }}{{ decimal_separator }}{{ split[1] }} {%- endmacro -%}        Receipt        
   {%- set grouped_items = group_items(flat_items|default(items), "external_identifier", "sku") -%}    {% with paginated_items = paginate(grouped_items, num_items_on_one_page) %}    {% for items in paginated_items %}        
       
           
           Giovanna Dodici            
               

               {{tenant_address.address_line_1}},                {{tenant_address.address_line_2 + ', ' if tenant_address.address_line_2 else ''}}                {{tenant_address.city}},                {{tenant_address.state + ' ' if tenant_address.state else ''}}                {{tenant_address.zip_code + ', ' if tenant_address.zip_code else ''}}                {{tenant_address.country_code}}            {%if store_phone_number%}
{{store_phone_number}}{% endif %}                

               

giovannadodici.com

           
           
               {% endfor %}    {% endwith %}    
``` ### Getting the sample data for the sales receipt template To see how to define a data payload to render for the sales receipt template, use the [get sample data method](/developers/tutorials/api/integration/nom/nom_platform_templates_api#operation/Get%20sample%20data): ```plaintext curl -H "Authorization: Bearer $AUTH_TOKEN" -X GET "https:///v0/d/templates/templates/sales_receipt/sample_data" ``` The response contains the sample data as JSON: ```json {  "customer_name": "John Doe",  "associate_name": "Example Associate Name",  "store_name": "Example Store Name",  "tenant_address": {    "name": "Example Fashion LLC",    "country_name": "United States of America",    "country_code": "US",    "city": "NEW YORK",    "zip_code": "10012",    "state": "NY",    "address_line_2": "",    "address_line_1": "70 WOOSTER ST"  },  "store_phone_number": "+123456789",  "order_number": "order-1234",  "external_id": "external-1234",  "currency_code": "USD",  "payment_method_label": "Credit Card",  "tax_exempt": false,  "extended_attributes": [    {      "name": "attr1",      "value": "val1"    }  ],  "flat_items": [    {      "product_name": "Awesome Pollo",      "product_id": "13451",      "fulfillment_group_type": "SHIPPING",      "external_identifier": {        "epc": "1234240000000",        "sku": "13451",        "abc": "2345511110002222"      },      "amount": 70,      "product_attributes": {        "variation_size_value": "XXL"      },      "price_net": 213.45,      "price_gross": 200.0,      "price_tax": 13.45,      "price_catalog": 180.0,      "item_discount": 3.92,      "item_order_discount": 3.92,      "product_image_url": "www.example.com",      "tax_method": "vat_included",      "discounts": [        {          "level": "order",          "discount_value": 90.0,          "discount_type": "percentage",          "reason": "ifkBiVvXba",          "coupon_code": "",          "promotion_uuid": "3efc6043-89fb-45ed-9e19-7ee558b5d309",          "price_adjustment": 3.92        },        {          "level": "item",          "discount_value": 3.92,          "discount_type": "fixed",          "reason": "ifkBiVvXba",          "coupon_code": "",          "promotion_uuid": "3efc6043-89fb-45ed-9e19-7ee558b5d312",          "price_adjustment": 3.92        }      ],      "group_id": "",      "extended_attributes": [        {          "name": "attr1",          "value": "val1"        }      ]    },    {      "product_name": "Average Polo",      "product_id": "13451",      "fulfillment_group_type": "IN_STORE_HANDOVER",      "external_identifier": {        "epc": "1234240000000",        "sku": "13451",        "abc": "2345511110002222"      },      "amount": 70,      "product_attributes": {        "variation_size_value": "XXL"      },      "price_net": 213.45,      "price_gross": 200.0,      "price_tax": 13.45,      "price_catalog": 180.0,      "item_discount": 3.92,      "item_order_discount": 3.92,      "product_image_url": "www.example.com",      "tax_method": "vat_included",      "discounts": [        {          "level": "order",          "discount_value": 90.0,          "discount_type": "percentage",          "reason": "ifkBiVvXba",          "coupon_code": "",          "promotion_uuid": "3efc6043-89fb-45ed-9e19-7ee558b5d309",          "price_adjustment": 3.92        },        {          "level": "item",          "discount_value": 3.92,          "discount_type": "fixed",          "reason": "ifkBiVvXba",          "coupon_code": "",          "promotion_uuid": "3efc6043-89fb-45ed-9e19-7ee558b5d312",          "price_adjustment": 3.92        }      ],      "group_id": "",      "extended_attributes": [        {          "name": "attr1",          "value": "val1"        }      ]    }  ],  "fulfillment_group_amounts": {    "IN_STORE_HANDOVER": {      "tax_lines": [        {          "name": "total eclipse tax",          "rate": 0.0098,          "amount": 123.23        }      ],      "sub_total": 217.37,      "grand_total": 90,      "taxes": 10,      "shipping_and_handling": 10    },    "SHIPPING": {      "tax_lines": [        {          "name": "blood moon tax",          "rate": 0.0098,          "amount": 334.23        }      ],      "sub_total": 217.37,      "grand_total": 90,      "taxes": 10,      "shipping_and_handling": 10    }  },  "amounts": {    "shipping_and_handling": 10,    "taxes": 10,    "grand_total": 90,    "sub_total": 217.37,    "tax_lines": [      {        "amount": 334.23,        "rate": 0.0098,        "name": "blood moon tax"      },      {        "amount": 123.23,        "rate": 0.0098,        "name": "total eclipse tax"      }    ]  },  "billing_address": {    "name": "Dr Mr John Christopher Doe Jr",    "country_name": "United States of America",    "country_code": "US",    "city": "Boston",    "zip_code": "02111",    "address_line_2": "",    "address_line_1": "745 Atlantic Ave",    "state": "MA",    "email": "jdoe@example.com"  },  "shipping_address": {    "name": "Dr Mr John Christopher Doe Jr",    "country_name": "United States of America",    "country_code": "US",    "city": "Boston",    "zip_code": "02111",    "address_line_2": "",    "address_line_1": "745 Atlantic Ave",    "state": "MA",    "email": "jdoe@example.com"  },  "created_at": "2016-10-07T07:10:38.506538",  "qr_code": "iVBORw0KGgoAAAANSUhEUgAAANwAAADcAQMAAAAhlF3CAAAABlBMVEX///8AAABVwtN+AAABCklEQVRYhe3XuxGDQAwE0L0hIKQESqE0UxqluARCAg8ye6fDB/5gzzhjlaFHpJGQgOXoURlQG7qcGSEkDmBU1rc3oJ2AbooZXISODStVeflADEtmFv6Gj9oK35QPcViFv+E6vEvqys/by8k+Ma4LYOm+hMUCEB7gJpjCuzgreqUqS1CbDfWMbgwcWOERpmZjo3E78EAD0ZNCn09eF33stonfuxDfvgi/wTGstbUrkDqw8doK+RC8fMsJ23r5BqT5FB6jB2sbg+dHMwPCiJajuDB220H4AYdY2Nx9RW03x++pcf3FtPQHkPZn6j6h8H94Ky4M4beYhzfetww/P3qh7RaAFRfG0/4UvsI7lvB94BBFc0MAAAAASUVORK5CYII=","timezone": "America/New_York",  "discounts": [    {      "level": "order",      "discount_value": 90.0,      "discount_type": "percentage",      "reason": "ifkBiVvXba",      "coupon_code": "",      "promotion_uuid": "3efc6043-89fb-45ed-9e19-7ee558b5d309",      "price_adjustment": 3.92    },    {      "level": "item",      "discount_value": 3.92,      "discount_type": "fixed",      "reason": "ifkBiVvXba",      "coupon_code": "",      "promotion_uuid": "3efc6043-89fb-45ed-9e19-7ee558b5d312",      "price_adjustment": 3.92    }  ],  "instruments": [    {      "instrument_id": "5efc6043-89fb-45ed-9e19-7ee558b5d316",      "payment_provider": "stripe",      "payment_method": "credit_card",      "currency_code": "USD",      "metadata": {        "instrument_details": {          "last4": "4242",          "brand": "MasterCard"        }      },      "amount": 60    },    {      "instrument_id": "6ifc6043-89fb-45ed-9e19-7ee558b5d315",      "payment_provider": "clutch",      "payment_method": "gift_card",      "currency_code": "USD",      "metadata": {},      "amount": 30    }  ],  "shipping_method": "in_store_handover",  "order_notes": [    {      "text": "Customer received a discount for their 10th order with us.",      "source": "354332bc-513d-4574-857f-16946a18ff52",      "source_type": "user",      "tags": ["loyal customer"],      "created_iat": "2016-10-07T07:10:38.506538"    },    {      "text": "This product is on us",      "source": "354332bc-513d-4574-857f-16946a18ff52",      "source_type": "user",      "tags": ["loyal customer"],      "created_iat": "2016-10-07T07:10:38.506538",      "item_id": "8681977b-78d5-48f4-92b9-b035d20009c8",      "product_id": "13451"    }  ] } ``` ### Previewing the sales receipt template Previewing a template with its accompanying sample data is useful to understand how to customize it. This is also helpful for testing your changes. Let's use the [preview template method](/developers/tutorials/api/integration/nom/nom_platform_templates_api#operation/Preview%20document) to accomplish this. 1. First [retrieve the template](/v1/docs/tutorial-creating-templates#retrieving-the-sales-receipt-template). 2. Then [get the sample data](/v1/docs/tutorial-creating-templates#getting-the-sample-data-for-the-sales-receipt-template) for the template. 3. In a JSON file named `request_body.json`, let's define the template as a string stripped of its carriage returns, the data as an object, and the content type as a string: ```json {  "template": "

User name: {{user_name}}

",  "data": {    "user_name": "John Doe"  },  "content_type": "html" } ``` 4. Let's render the output by calling the [preview template method](/developers/tutorials/api/integration/nom/nom_platform_templates_api#operation/Preview%20document): ```plaintext curl -X POST "https:///v0/d/templates/templates/sales_receipt/preview" \     -H "Authorization: Bearer $AUTH_TOKEN" -d @request_body.json ``` ## Creating a customized sales receipt template We can create or customize our own sales receipt template now that we know how to get the template and sample data and use them together. > [!TIP] > Note > > This example sales receipt template is optimized to print receipts via receipt printers that print on 3.5 inch paper. Using the fields and data from the [sample data](/v1/docs/tutorial-creating-templates#getting-the-sample-data-for-the-sales-receipt-template) , let's create a new template `sales_receipt.j2`: ```plaintext {%- from 'macros' import positive_currency, negative_currency with context -%} {%- import 'tenant' as tenant -%} {% set total_items = flat_items|length %} {% set total_instruments = instruments|length %} {% set total_credit_cards = instruments|selectattr('payment_method', 'equalto', 'credit_card')|list|length|int %} {% set top_info_height = 0 %} {% if self.top_info() %}  {% if (billing_address and billing_address.name) or (shipping_address and shipping_address.name) %}    {% set top_info_height = 0.77 %}  {% else %}    {% set top_info_height = 0.65 %}  {% endif %} {% endif %} {% set item_list_height = 0 %} {% if self.item_list_sales() %}  {% set item_list_height = (total_items * 0.46) + (item_discounts * 0.32) + 0.265 %} {% endif %} {% set pricing_info_height = 0 %} {% if self.pricing_info_sales() %}  {% set pricing_info_height = (order_discounts * 0.14) + 0.46 %} {% endif %} {% set payment_info_height = 0 %} {% if self.payment_info() %}  {% set payment_info_height = 0.35 + ((total_instruments - total_credit_cards) * 0.152) + (total_credit_cards * 0.304) %} {% endif %} {% set receipt_height = 0.3 + top_info_height + item_list_height + pricing_info_height + payment_info_height %}                
               

                               {{ store_address.address }}                    

       {% if store_phone_number %}        

phone: {{store_phone_number}}

{% endif %} {% if tenant.emails.customer_service %}        

email: {{tenant.emails.customer_service}}

{% endif %} {% if tenant.vat_number %}        

VAT {{tenant.vat_number}}

{% endif %}    
   {% block top_info %}    
       

Order no. {{ order_details.order_id }}

   
   {% endblock %}    {% block item_list_sales %}    
       
           

Description

           

Price

       
       {% set show_gross_prices = flat_items|selectattr("tax_method", "equalto", "vat_included")|list|count > 0 -%}        
           
               

{{ item.product_name }}

           
           
               {% if show_gross_prices %}                

{{ positive_currency(item.price_gross) }}

               {% else %}                

{{ positive_currency(item.price_net) }})

               {% endif %}            
       
       {% endfor %}    
   {% endblock %}    {% block pricing_info_sales %} {% set show_gross_prices = flat_items|selectattr("tax_method", "equalto", "vat_included")|list|count > 0 -%}    
       
           

Subtotal

           {% if show_gross_prices %}            

{{ positive_currency(amounts.sub_total + amounts.taxes) }}

           {% else %}            

{{ positive_currency(amounts.sub_total) }}

           {% endif %}        
       
           

Taxes{%- if show_gross_prices -%}(Incl){% else %}(Excl){%- endif -%}

           

{{ positive_currency(amounts.taxes) }}

       
       
           

Total

           

{{ positive_currency(amounts.grand_total) }}

       
   
   {% endblock %}    {% block payment_info %}    
       
           

Payments

       
       {% for instrument in instruments %} {%- if instrument.payment_method == "credit_card" -%}        
           

Credit Card

           

{{ positive_currency(instrument.amount) }}

       
       {%- else -%}        
           

{{ instrument.payment_method }}

           

{{ positive_currency(instrument.amount) }}

       
       {%- endif -%} {% endfor %}    
   {% endblock %}     ``` ### Creating a fiscal signature template In some countries, retailers must print the `fiscal signature` on the receipts. For more details, see [Adding fiscal signatures to receipts](/v1/docs/about-internationalization#adding-fiscal-signatures-to-receipts). For Portugal refer to [this section](/v1/docs/tutorial-creating-templates#creating-a-portugal-receipt-template). The `f11n` property includes the list of transactions under the `transactions` field, and is available under sales, return, or exchange receipt templates. > [!NOTE] > Important > > The retailer is responsible for verifying local regulations and ensuring compliance of the receipt in each country where fiscal regulations apply. > [!TIP] > Note > > - In fiscal countries, the receipts generated in `Offline Mode` may not have the `f11n` property. Based on the selected fiscal signing strategy, receipts may therefore be generated without a fiscal signature. For more details, see [Configuring Offline Mode in fiscal countries](/v1/docs/enabling-newstore-associate-app-to-be-used-offline#configuring-offline-mode-in-fiscal-countries). > - Use the parameter `is_copy` in the template to determine whether the current receipt is a copy or not. 1. To create the fiscal signature template under `fiscal_signature.j2`, see the following code sample: ```plaintext {# MAIN MACRO - USE IN TEMPLATES TO DISPLAY FISCAL SIGNATURE FOR ANY COUNTRY #} {%- macro showFiscalSignature(f11n, txnType) -%}  {% if f11n is defined and f11n %}    {# override styles in your template #}    {{inlineStyles()}}    {#      extracting specific f11nTransaction:      1. if txnType is defined, filtering just txn with specific type      2. selecting first transaction in the list    #}    {% if txnType %}      {% set transactions = f11n.transactions | selectattr('type','equalto', txnType) | list %}    {% else %}      {% set transactions = f11n.transactions %}    {% endif %}    {% if transactions|length > 0 %}      {% set f11nTransaction = transactions[0] %}    {% endif %}    {% if f11nTransaction is defined %}      {# temporary signature is provided in case there is a failure with 3rd party fiscal provider #}      {% set f11nSignature = f11nTransaction.signature or f11nTransaction.temporarySignature %}      
       {% if f11n.countryCode == "AT" %}          {{showFiscalSignatureAT(f11nSignature)}}        {% elif f11n.countryCode == "DE" %}          {{showFiscalSignatureDE(f11nTransaction)}}        {% elif f11n.countryCode == "FR" %}          {{showFiscalSignatureFR(f11nSignature)}}        {% elif f11n.countryCode == "MC" %}          {{showFiscalSignatureFR(f11nSignature)}}        {% elif f11n.countryCode == "IE" %}          {{showFiscalSignatureIE(f11nTransaction)}}        {% elif f11n.countryCode == "IN" %}          {{showFiscalSignatureIN(f11nTransaction)}}        {% elif f11n.countryCode == "PR" %}          {{showFiscalSignaturePR(f11nTransaction)}}        {% elif f11n.countryCode == "SE" %}          {{showFiscalSignatureSE(f11nTransaction)}}        {% endif %}      
   {% endif %}  {% endif %} {%- endmacro -%} {# ----------------------------------------------------------------------------------------------- #} {# AUSTRIA #} {%- macro showFiscalSignatureAT(signature) -%}  {{showFiscalInfo('FISCAL', statusAT(signature))}}  {{showFiscalInfo('RKSV-Identification', signature.cashBoxName)}}  {{showFiscalInfo('RKSV-Receipt number', signature.receiptId)}}  {% if signature.environment != 'production' %}    {{showFiscalInfo('ENV', signature.environment)}}  {% endif %}  {{showFiskaltrustQRCode(signature)}} {%- endmacro -%} {%- macro statusAT(signature) -%}  {% if signature.state == 'OK' %}    OK  {% elif signature.state == 'OUT_OF_SERVICE' %}    SIGNATURE DEVICE FAILED (OOS)  {% elif signature.state == 'SSCD_TEMPORARY_OUT_OF_SERVICE' %}    SIGNATURE DEVICE FAILED (TEMP)  {% elif signature.state == 'SSCD_PERMANENETLY_OUT_OF_SERVICE' %}    SIGNATURE DEVICE FAILED (PERM)  {% elif signature.state == 'SUBSEQUENT_ENTRY_ACTIVATED' %}    OK  {% elif signature.state == 'MONTHLY_REPORT_DUE' %}    OK  {% elif signature.state == 'ANNUAL_REPORT_DUE' %}    OK  {% elif signature.state == 'MESSAGE_PENDING' %}    OK  {% elif signature.state == 'SSCD_BACKUP_IN_USE' %}    SIGNATURE DEVICE FAILED (BCKP)  {% else %}    {{signature.state}}  {% endif %}  {% if signature.stateData.Signing == false %}    

SIGNING NOT REQUIRED

 {% endif %} {%- endmacro -%} {# ----------------------------------------------------------------------------------------------- #} {# GERMANY #} {%- macro showFiscalSignatureDE(transaction) -%}  {% set signature = transaction.signature or transaction.temporarySignature %}  {% if transaction.type.startswith('foreign') %}    
Auslandsverkäufe
 {% endif %}  {{showFiscalInfo('FISCAL', statusDE(signature))}}  {% if signature.environment != 'production' %}    {{showFiscalInfo('ENV', signature.environment)}}  {% endif %}  {{showFiscalInfo('Receipt Id', signature.receiptId)}}  {{showSignatureItem(signature, 'CERTIFICATION_IDENTIFICATION', 'TSE - Zertifizierung-Id')}}  {{showSignatureItem(signature, 'TSE_SERIAL_NUMBER', 'TSE - Seriennummer')}}  {{showSignatureItem(signature, 'RECEIPT_QR_VERSION', 'TSE - QR-Version')}}  {{showSignatureItem(signature, 'RECEIPT_POS_SERIAL_NO', 'TSE - Seriennummer Kasse')}}  {{showSignatureItem(signature, 'RECEIPT_PROCESSTYPE', 'TSE - Prozesstyp')}}  {{showSignatureItem(signature, 'RECEIPT_PROCESSDATA', 'TSE - Prozessdaten')}}  {{showSignatureItem(signature, 'RECEIPT_TRANSACTION_NUMBER', 'TSE - Transaktions-Zähler')}}  {{showSignatureItem(signature, 'RECEIPT_SIGNATURE_COUNTER', 'TSE - Signatur-Zähler')}}  {{showSignatureItem(signature, 'RECEIPT_START_TIME', 'TSE - Start')}}  {{showSignatureItem(signature, 'RECEIPT_LOGTIME', 'TSE - Stop')}}  {{showSignatureItem(signature, 'RECEIPT_SIGNATURE_ALGORITHM', 'TSE - HashAlgorithmus')}}  {{showSignatureItem(signature, 'RECEIPT_LOGTIME_FORMAT', 'TSE - Zeitformat')}}  {{showSignatureItem(signature, 'RECEIPT_SIGNATURE', 'TSE - Signatur')}}  {{showSignatureItem(signature, 'RECEIPT_PUBLIC_KEY', 'TSE - PublicKey')}}  {{showSignatureItem(signature, 'RECEIPT_PROCESS_START', 'TSE - Vorgangsbeginn')}}  {{showSignatureItem(signature, 'ARCHIVING_REQUIRED', 'Archivierung erforderlich')}}  {{showSignatureItem(signature, 'NOTIFICATION', 'Benachrichtigung')}}  {{showSignatureItem(signature, 'INFORMATION_NOTIFICATION', 'Information')}}  {{showSignatureItem(signature, 'ALERT_NOTIFICATION', 'Alarm')}}  {{showSignatureItem(signature, 'FAILURE_NOTIFICATION', 'Fehler')}}  
{{showFiskaltrustQRCode(signature)}}
{%- endmacro -%} {%- macro statusDE(signature) -%}  {% if signature.state == 'OK' %}    OK  {% elif signature.state == 'OUT_OF_SERVICE' %}    TSE FAILED (OOS)  {% elif signature.state == 'TSE_DEVICE_COMM_BROKEN' %}    TSE DEVICE COMM. FAILED  {% elif signature.state == 'LATE_SIGNING_MODE' %}    OK  {% elif signature.state == 'MESSAGE_PENDING' %}    OK  {% else %}    {{signature.state}}  {% endif %} {%- endmacro -%} {# ----------------------------------------------------------------------------------------------- #} {# FRANCE #} {%- macro showFiscalSignatureFR(signature) -%}  

Caractéristiques de sécurité

   {{showFiskaltrustQRCode(signature)}}  
   {{showSignatureItems(signature)}}  
{%- endmacro -%} {%- macro statusFR(signature) -%}  {% if signature.state == 'OK' %}    OK  {% elif signature.state == 'OUT_OF_SERVICE' %}    MODE DÉGRADÉ  {% elif signature.state == 'LATE_SIGNING_MODE' %}    MODE DE SIGNATURE TARDIVE  {% elif signature.state == 'MESSAGE_PENDING' %}    MESSAGE EN ATTENTE  {% else %}    {{signature.state}}  {% endif %} {%- endmacro -%} {# ----------------------------------------------------------------------------------------------- #} {# INDIA #} {%- macro showFiscalSignatureIN(transaction) -%}  {% set signature = transaction.signature %}  {% if signature.environment != 'production' %}  
   ENV: {{signature.environment}}  
 {% endif %}  
   Receipt number: {{signature.receiptNumber}}  
{%- endmacro -%} {# ----------------------------------------------------------------------------------------------- #} {# IRELAND #} {%- macro showFiscalSignatureIE(transaction) -%}  {% set signature = transaction.signature %}  {% if signature.environment != 'production' %}  
   ENV: {{signature.environment}}  
 {% endif %}  
   {{showQRCode(signature.digitalSignatureQrCode)}}  
{%- endmacro -%} {# ----------------------------------------------------------------------------------------------- #} {# PUERTO RICO #} {%- macro showFiscalSignaturePR(transaction) -%}  {% set signature = transaction.signature or transaction.temporarySignature %}  {% if signature.environment != 'production' %}    
ENVIRONMENT: {{signature.environment}}
 {% endif %}  
TRANSACTION NO: {{transaction.transactionNumber}}
 {{controlNumberPR(transaction)}}  {{statusPR(transaction)}} {%- endmacro -%} {%- macro statusPR(transaction) -%}  {% if transaction.signature %}    {% if transaction.signature.processor %}      
{{transaction.signature.processor}}
     
{{transaction.signature.processorMessage}}
   {% elif transaction.signature.signingRequired == false %}      
SIGNING NOT REQUIRED
   {% endif %}  {% endif %} {%- endmacro -%} {%- macro controlNumberPR(transaction) -%}  {% if transaction.signature %}    {# Print control number only for the first copy of sale transaction #}    {% if transaction.signature.controlNumber and transaction.type == 'sale' and is_copy != true %}      
CONTROL: {{transaction.signature.controlNumber}}
   {% endif %}  {% elif transaction.temporarySignature %}    
CONTROL: NOT AVAILABLE
 {% endif %} {%- endmacro -%} {# ----------------------------------------------------------------------------------------------- #} {# SPAIN #} {%- macro showFiscalReceiptNumberES(f11n) -%}  {{getDataFromSignature(f11n, "receiptNumber")}} {%- endmacro -%} {# ----------------------------------------------------------------------------------------------- #} {# SWEDEN #} {%- macro showFiscalSignatureSE(transaction) -%}  {% set signature = transaction.signature or transaction.temporarySignature %}  
FISCAL: {{statusSE(transaction)}}
 
Receipt No.: {{transaction.transactionNumber}}
 {% if signature.environment != 'production' %}    
ENV: {{signature.environment}}
 {% endif %}  
Cash register: {{signature.cashRegisterName}}
 
CCU: {{signature.controlUnitSerial}}
{%- endmacro -%} {%- macro statusSE(transaction) -%}  {% if transaction.signature %}    OK  {% elif transaction.temporarySignature %}    CCU OUT OF SERVICE  {% endif %} {%- endmacro -%} {# ----------------------------------------------------------------------------------------------- #} {# NORWAY #} {%- macro showCashRegisterIdFromSignatureNO(f11n, index) -%}  {{getDataFromSignature(f11n, "cashRegisterId", index)}} {%- endmacro -%} {# ----------------------------------------------------------------------------------------------- #} {# COMMON #} {%- macro showFiskaltrustQRCode(signature) -%}  {% for signatureItem in signature.signatureItems %}    {% if signatureItem.format == 'QR_CODE' %}      {{showQRCode(signatureItem.data)}}    {% endif %}  {% endfor %} {%- endmacro -%} {%- macro showQRCode(qrCode) -%}  
   QR-Code  
{%- endmacro -%} {%- macro showSignatureItem(signature, type, caption) -%}  {% for signatureItem in signature.signatureItems %}    {% if signatureItem.type == type %}      {{showFiscalInfo(caption, signatureItem.data)}}    {% endif %}  {% endfor %} {%- endmacro -%} {%- macro showFiscalInfo(caption, data) -%}  
   {{caption}}:    {{data}}  
{%- endmacro -%} {%- macro showSignatureItems(signature) -%}  {% for signatureItem in signature.signatureItems %}    {% if signatureItem.format == 'TEXT' %}      {{showSignatureText(signatureItem.caption, signatureItem.data)}}    {% endif %}  {% endfor %} {%- endmacro -%} {%- macro showSignatureText(caption, data) -%}  
{{caption}}
 
{{data}}
{%- endmacro -%} {%- macro getDataFromSignature(f11n, key, index) -%}  {% if f11n is defined and f11n %}    {% if index %}      {% set f11nTransaction = f11n.transactions[index] %}    {% else %}    {% set f11nTransaction = f11n.transactions[0] %}    {% endif %}    {% if f11nTransaction is defined %}      {% set signature = f11nTransaction.signature or f11nTransaction.temporarySignature %}      {% if signature is defined %}        {{ signature[key] }}      {% endif %}    {% endif %}  {% endif %} {%- endmacro -%} {%- macro inlineStyles() -%}   {%- endmacro -%} ``` 1. Import the `showFiscalSignature` function, available under the fiscal signature template, into the receipt template: ```plaintext {%- from 'fiscal_signature' import showFiscalSignature with context -%} ``` 1. Call the `showFiscalSignature` function from the receipt template: ```plaintext
 {{ showFiscalSignature(f11n) }}
``` #### Creating a Portugal receipt template In Portugal, the fiscal provider EFSTA generates the **entire receipt as a PDF**. NewStore converts this PDF to a base64-encoded PNG image and returns it in the `f11n` property. Unlike other countries, the Jinja2 template does not build the receipt layout, it only **embeds the pre-rendered receipt image**. > [!NOTE] > Important > > Do **not** add item lists, totals, tax breakdowns, payment information, or fiscal signature sections to Portugal templates. The EFSTA-generated image already contains the complete fiscal document. This approach applies exclusively to Portugal `PT`) with EFSTA as the fiscal provider. The receipt image is available as a base64-encoded PNG string at: ```plaintext f11n.transactions[0].signature.receiptData ``` It is generated **on-demand** each time the receipt is fetched (not stored permanently). For **copy receipts**, EFSTA automatically adds "Cópia Cliente". No template logic is needed. The template uses a `$$height$$` placeholder for the page and image height. This is dynamically replaced at render time with the actual pixel height of the receipt image. Here is a sample Portugal receipt template, optimized for **80mm** thermal receipt printers: ```xml {%- from 'fiscal_signature' import getDataFromSignature with context -%} {% set receipt = getDataFromSignature(f11n, "receiptData") %}                     ``` It uses the `getDataFromSignature` macro from the shared `fiscal_signature` template to extract `receiptData`. For details on this macro, see [Creating a fiscal signature template](/v1/docs/tutorial-creating-templates#creating-a-fiscal-signature-template). ## Updating templates We'll work through this process using the packing slip template as an example. The packing slip contains the full name of the associate who picked and packed items in the order. You can also specify the billing address of the customer in the packing slip, if required. To comply with privacy rules, we'll remove the associate's personal information from the template. > [!NOTE] > Important > > Ensure that you work on the correct instance of the template and sync all your changes to other instances of the template stored across NewStore. 1. Let's first retrieve the packing slip from our production environment. In this example we're using `en_US` as the template locale. ```plaintext curl -H "Authorization: Bearer $AUTH_TOKEN" \    -X GET "https://{retailer}.p.newstore.net/v0/d/templates/templates/packing_slip/localization/en_US" \    > packing_slip.j2 ``` Here's an example of what you'll see in the template: ```plaintext        Packing slip    
{% with paginated_items = paginate(flat_items, 6) %} {% for items in paginated_items %}    
       
           
               
                   

{{from_address.address_line_1}}{{from_address.address_line_2|format_if_valid(' {}')}}, {{from_address.city}}{{from_address.state|format_if_valid(', {}')}}{{from_address.zip_code|format_if_valid(' {}')}}

               
           
           
               
                   

Deliver to:

                   

{{ to_address.name }}

                   

{{ to_address.address_line_1 }}{{to_address.address_line_2|format_if_valid(' {}')}}

                   

{{ to_address.city }}{{to_address.state|format_if_valid(', {}')}}{{ to_address.zip_code|format_if_valid(' {}')}}

                   

{{ to_address.country_name }}

               
               
                   

{{ order_details.consumer_name }}

                   

{{ format_date(order_details.placed_at, store_timezone) }}

                   {% if order_details.shipping_carrier and order_details.shipping_type_name %}                        

{{ order_details.shipping_carrier }}, {{ order_details.shipping_type_name }}

                   {% endif %}                    

{{ order_details.packer_id }}

               
               
                   

Customer:

                   

Date:

                   {% if order_details.shipping_carrier and order_details.shipping_type_name %}                        

Shipping:

                   {% endif %}                    

Agent:

               
           
           
               
               
               
                   Packing Slip                
               
                   {{ order_details.order_id }} - Package {{ current_package }} of {{ number_of_packages }}                
           
                                                                                                                                                                                                               {% for item in items %}                                                                                                                                                        {% endfor %}                
DescriptionItem IDQuantity
                                   {{ item.name }}
                                   Size {{ item.product_attributes.variation_size_value }}                                
                                    {{ item.external_identifier.epc if item.external_identifier and item.external_identifier.epc else '---' }}                                                                     1                                
               
           
                   
   
   {% endfor %}    {% endwith %}
``` 2. To find the field name that contains the associate's personal information, let's download the sample data for the packing slip. ```plaintext curl -H "Authorization: Bearer $AUTH_TOKEN" \    -X GET "https://{retailer}.p.newstore.net/v0/d/templates/templates/packing_slip/sample_data" \    > packing_slip.mock.json ``` The `order_details->packer_id` field contains the associate's name. ```json {    "order_details": {        "placed_at": "2017-01-03T15:58:32.008988",        "shipping_type_name": "Same Day",        "consumer_name": "Janet Doe",        "order_id": "TH-000000872",        "shipping_carrier": "DELIV",        "external_order_id": "ORD-000000872",        "packer_id": "Johny Doe"    } } ``` 3. Let's remove instances where this field was used in the template. For example, you'll see , `<p>{{ order_details.packer_id }}</p>` wrapped in HTML. Removing this line removes the name of the associate and the related content from the Jinja2 packing slip template. 4. Now, we can upload the modified template. ```plaintext curl -H "Authorization: Bearer $AUTH_TOKEN" \  -X PUT "{retailer}.p.newstore.net/v0/d/templates/templates/packing_slip/localization/en_US" \  -d @packing_slip.j2 ``` > [!TIP] > Note > > Ensure that your changes are synced to other instances of this template in NewStore. ## Best practices for creating templates ### Using helper functions You can find helper functions in the NewStore repository to help you set up templates. For example, below is a function that you can use in a sales receipt template. It covers all the `if-else` cases in payment information, to decrease complexity in the template. ```plaintext def get_instrument_info(instrument):    """    Gets the instrument brand and additional infromation from the metadata    """    metadata = instrument['metadata']    payment_method = instrument['payment_method']    payment_method_mapped = payment_method_dict(payment_method) or desnake(payment_method)    instrument_info = {        'brand': payment_method_mapped,        'info': ''    }    # if there is no metadata return payment_method at least    if not metadata:        return instrument_info    if payment_method == 'credit_card':        last4 = metadata.get('instrument_details', {}).get('last4', '')        instrument_info['brand'] = metadata.get('instrument_details', {}).get('brand', '')        if last4:            instrument_info['info'] = '*' * 4 + last4    elif payment_method == 'paypal':        instrument_info['info'] = metadata.get('instrument_details', {}).get('email', '')    elif payment_method == 'gift_card':        instrument_info['info'] = metadata.get('instrument_details', {}).get('card_id', '')    if payment_method != 'cash' and not instrument_info['info']:        logger.warning(            'failed to get payment method info for payment method with type %s and metadata %s',            payment_method, metadata)    return instrument_info ``` ### Working with email templates You can customize the subject and the body of email messages, and update the email template to include images, your logo, and links to websites. Linking images is good practice since the same link can be reused, but they must be online in order to be available. Some email providers don't use current HTML standards. Ensure that your email templates adhere to the email provider's requirements. For example, ensure that the fonts you use in the template are allowed by the email provider. Most email viewers will not correctly render CSS Flexbox or CSS Grid, so use HTML tables to position your components in the email. ### Working with print templates To ensure that your receipt templates are rendered correctly as PDFs, define the size accurately: - **Standard letter-sized PDF receipts**: Set the page height as 11" and the width as 8.5" in the CSS. - **Ribbon receipts**: The length of these receipts is dynamic and depends on the number of line items it contains. Ensure that you calculate the height for the template as a sum of the individual components it can contain. ### Importing templates If you know you're going to reuse data across multiple templates, to prevent duplication of code create this data in a separate file and import it into each template. For example, let's define retailer-specific data in tenant.j2, which we can import into another template: ```plaintext {%- set id = 'dodici' -%} {%- set name = 'Dodici' -%} {%- set email_logo = 'https://assets.example.com/dodici/logo.png' -%} {%- set phone = '+49 55 55 55 55' -%} {%- set emails = {    'contact': 'customerservice@dodici.com' } -%} {%- set urls = {    'home': 'www.dodici.com',    'instagram': 'https://www.instagram.com/dodici/' } -%} {%- set policies = {    'return_period': '14' } -%} {%- set fonts = {    'roboto': 'https://fonts.gstatic.com/s/roboto/v19/KFOmCnqEu92Fr1Mu7GxKKTU1Kvnz.woff2' } -%} ``` In another template file, we can import `tenant.j2`: ```plaintext {%- import 'tenant' as tenant -%}      
      {% if tenant.emails.contact %}      

Email: {{tenant.emails.contact}}

{% endif %} {% if tenant.policies %}      

Return policies: {{tenant.policies}}

{% endif %}  
  ``` ### Using predefined functions We have predefined functions from our templating engine, which you can use to create your templates. | Function | Description | | --- | --- | | `format_currency(amt)` | - Formats the amount to have two digits after the period. | | @environmentfunction `format_date(env, dt, timezone=None, format='long')` | - Formats date in template. - Uses jinja2 environmentfunction decorator. | | @environmentfunction `format_time(env, dt, timezone, format='short')` | - Formats time in template. - Uses jinja2 environmentfunction decorator. | | `desnake(s)` | - Converts snake case to normal case. | | `paginate(items, page_limit)` | - Groups all items into pages depending on the page limit. | | `group_items(items, \*keys)` | - Groups a set of flat items according to a key (or nested keys) in the item dictionaries. - Items from the different fulfillment groups of the mixed order are not grouped together. - Sums up the price details of each item. | | `items \| indexed` | - A jinja2 filter that adds a field `index` to the given items that enumerates them. | | `is_mixed(items)` | - Returns true if the given products have a different fulfillment group type. | | `items \| with_fulfillment_group(ff_group_type)` | - A jinja2 filter that returns a list of products with the given `fulfillment_group_type` - Supported fulfillment group types are IN_STORE_HANDOVER and SHIPPING. | | `items \| sorted_by_fulfillment_group(priority)` | - A jinja2 filter that orders the given items by `fulfillment_group_type` key using the given priority list. - The default priority is`['IN_STORE_HANDOVER', 'SHIPPING']`. - Supported fulfillment group types are `IN_STORE_HANDOVER` and `SHIPPING`. | | `currency_symbol(currency)` | - Converts currency letters to its symbol if it exists. | | `get_instrument_info(instrument)` | - Gets the instrument brand and additional information from the metadata. | | `total_discount_per_level(discounts, key)` | - Calculates the total price adjustment of all discounts with the given level. | | `group_items_by_fields(items, fields)` | - Reduces each item to the requested fields and groups items that are identical across those fields. Each group gains a quantity key counting how many original items it represents. Fields not listed are dropped, and first-occurrence order is preserved. Unlike `group_items`, it does not sum price details. - This example uses `group_items_by_fields` to combine identical line items and display their quantity: ```plaintext {% set grouped = group_items_by_fields(items, ['product_name', 'product_attributes', 'price_net']) %} {% for item in grouped %} {{ item.product_name }} × {{ item.quantity }} {% endfor %} ``` | | `render_qrcode(data)` | - Creates a QR code from the given string and returns it as a PNG data URI. | | `render_barcode(data, printer_dpi, dots_per_bar)` | - Creates a Code 128 barcode from the given text or whole number and returns it as an image for an `<img>` tag. The barcode is generated during rendering, without any network call. - Use it in PDF documents. Gmail does not display these images. - Accepts ASCII text and whole numbers. Format any other number before passing it. - Returns an empty string when the value is missing, empty, or contains characters outside ASCII. Wrap the image in a condition, otherwise the PDF shows the image's alt text in its place. - The value is not printed under the bars. Print it in the template when it must be readable. - For receipts printed on a standard receipt printer, call `render_barcode(value)` with no other setting. - For any other printer, set its resolution so the bars print sharp. See **Choosing printer settings for barcodes** below. - This example prints a barcode for each line item that has a SKU: ```plaintext {% set barcode = render_barcode(item.sku) %} {% if barcode %} {{ item.sku }} {% endif %} ``` | | `value \| abs` | - A jinja2 filter that returns the absolute value of a number, falling back to 0 if the value is invalid. | | `value \| format_if_valid(mask)` | - A jinja2 filter that applies a format mask only when the value is non-empty. | | `code \| country_name` | - A jinja2 filter that translates an ISO 3166-1 alpha-2 country code to a localized country name using the template locale. | ### Choosing printer settings for barcodes A printer prints in tiny dots. A barcode scans reliably when each bar is a whole number of dots wide. `render_barcode` sizes the bars for you once it knows the printer. 1. **Find your printer's resolution.** It is listed in the printer's specifications as dpi (dots per inch), for example 203 dpi or 300 dpi. 2. **Pass it as** `printer_dpi`**, with the** `dots_per_bar` **from the table below.** For example, on a 300 dpi label printer: `render_barcode(item.sku, printer_dpi=300, dots_per_bar=3)` 3. **Test-print and scan.** If the scanner struggles, add one dot per bar: `dots_per_bar=4`. | Printer | `printer_dpi` | Suggested `dots_per_bar` | | --- | --- | --- | | Receipt printer (most thermal models) | 203 (default) | 2 (default) | | Label printer | 300 | 3 | | Office laser printer | 600 | 4 | - `printer_dpi` accepts whole numbers from 150 to 1200, `dots_per_bar` from 1 to 10. - The thinnest bar must come out between 0.127 mm and 1 mm: thinner bars do not scan, wider ones do not fit. Its width is `dots_per_bar × 25.4 / printer_dpi` mm. - Any other value falls back to 203 dpi and 2 dots per bar. - Do not resize the barcode image with CSS. The bars then stop lining up with the printer's dots. - Each extra dot per bar makes the whole barcode wider. On narrow labels with long values, keep `dots_per_bar` low. On a 203 dpi printer, 2 is the lowest: for long values, print on a wider label or shorten the value. ### Macro naming considerations Name your macros in a way that is clear to understand. As an example, let's take the following macro. It formats the currency depending on whether the amount is negative or positive but its name and its parameters doesn't tell us what the function does. ```plaintext {%- macro currency(amount, isNegative=false) -%}  {% set split = format_currency(amount|abs).split(decimal_separator, 1) %}        {% if split[0] == '0' and split[1] == '00' %}      {% elif isNegative == true %}          -      {% else  %}      {% endif %}      {{ currency_symbol(currency_code) }}      {{ split[0] }}      {{ decimal_separator }}      {{ split[1] }}   {%- endmacro -%} ``` We can create more meaningful macros by giving them names that explain their function and have them call the previous macro with the correct parameters. ```plaintext {%- macro positive_currency(amount) -%}    {{ currency(amount, false) }} {%- endmacro -%} {%- macro negative_currency(amount) -%}    {{ currency(amount, true) }} {%- endmacro -%} {%- macro currency(amount, isNegative=false) -%}    {% if tenant.business_rules.currency == 'try_symbol' %}        {% set currency_sym = currency_symbol(currency_code) %}    {% elif tenant.business_rules.currency == 'use_code' %}        {% set currency_sym = currency_code %}    {% else %}        {% set currency_sym = currency_symbol(currency_code) %}    {% endif %}    {% set split = format_currency(amount|abs).split(decimal_separator, 1) %}            {% if isNegative == true %}            -        {% endif %}        {% if currency_sym|length <= 1 %}            {{ currency_sym }}        {% endif %}        {{ split[0] }}{{ decimal_separator }}{{ split[1] }}        {% if currency_sym|length > 1 %}             {{ currency_sym }}        {% endif %}     {%- endmacro -%} ``` This macro checks to see whether `try_symbol` or `use_code` is set to determine whether to use the currency symbol or the currency code. It formats the currency amount depending on whether it is positive or negative and puts the currency symbol/code before the amount if it is not more than 1 character long. ### Supporting mixed orders Mixed orders contain items with different fulfillment group types. Supported fulfillment group types are `IN_STORE_HANDOVER` and `SHIPPING`. In order to group items on the receipt by fulfillment group type, we can use the following snippet to initialize `is_mixed_order` flag and two lists of items `shipping_items` and `in_store_handover_items`. ```plaintext {% set is_mixed_order = False %} {% if is_mixed(items) %}   {% set items = items | sorted_by_fulfillment_group | indexed %}   {% set is_mixed_order = True %}   {% set shipping_items = items | with_fulfillment_group('SHIPPING') %}   {% set in_store_handover_items = items | with_fulfillment_group('IN_STORE_HANDOVER') %} {% endif %} ``` When iterating over the items, we can use the following snippet to print the header of the fulfillment group. ```plaintext {% for item in items %}  ...   {% if is_mixed_order %}      {% if item == shipping_items | first %}        

Shipped

     {% elif item == in_store_handover_items | first %}        

In-store

     {% endif %}   {% endif %}  ... {% endfor %} ``` ### Defining fallbacks for external resources If you provide CSS or fonts hosted by an external source, ensure the external source is highly reliable. If the resource cannot be downloaded, it will be ignored, and the template will be rendered with a default CSS or font. We suggest providing a fallback font in your font-family CSS definition and testing your template with the fallback font. Example: ```css @font-face { font-family: 'YourFontName'; url('http://domain.example/fonts/font.ttf'); } body {  font-family: 'YourFontName', Arial, Helvetica, sans-serif; } ``` The unavailability of external resources may lead to the generated document looking different than usual. For example, the printed receipt the customer receives may look different. To identify which external resource is currently unavailable, we recommend checking the error logs in the template editor in Omnichannel Manager. ## Testing templates Here are general guidelines for testing template changes: - Use the [preview template method](/developers/tutorials/api/integration/nom/nom_platform_templates_api#operation/Preview%20document) to preview the template as HTML, PDF, or text. - Use the [update template method](/developers/tutorials/api/integration/nom/nom_platform_templates_api#operation/Update%20template) to update the template in the sandbox or staging environment. - Download the NewStore Associate App for your retailer and create a business event (like triggering an order and paying with cash) to generate a document. - Navigate to NewStore Omnichannel Manager, click on an Order ID, scroll to `Documents` and download one of the documents to view it. - When previewing templates, ensure that templates that are included in other templates (`macros.j2`, `printbase.j2`, `emailbase.j2`) are uploaded to the system first - Our preview API isn’t locale-aware: a workaround is to add a locale field to the mock data If you run into any issues, contact the [support team](https://help.newstore.com). ## Debugging templates General guidelines for debugging templates: 1. Preview your templates before you upload them. Remember to upload base templates and any imported ones beforehand. You can use a local CSS file for the preview call. 2. If your templates contain syntax errors, expect the following error when trying to preview the template: ```plaintext HTTP Error 500: Internal Server Error {    "request_id": "94157.2.18",    "messages": [        "unexpected '%' (at input line 1), code=template_syntax_error"    ] } ``` 3. Fix the errors and try to generate a preview again. 1. Certain template errors may not be detectable during preview. For instance, an `if` condition error might only become apparent when the `if` condition is true. These errors can only be identified when documents are generated using the template. To check for any template errors that occurred during actual document generation, in Omnichannel Manager go to `Tools` > `Templates Editor`, and click `See errors` on the top of the page. Alternatively you can use this API to get list of errors: ```plaintext curl -H "Authorization: Bearer $AUTH_TOKEN" \    -X GET "https://{retailer}.p.newstore.net/v0/d/templates/logs" \ ``` ### Environments We work with the following environments at NewStore: demo (d), development (v), sandbox (x), staging (s), production (p). As the integrations team, you should be working with the templates API against the sandbox environment. Note that clients can always make changes to the templates in the production environment. ### Deploying templates Upload your finished templates to the sandbox, staging, and production environment. You should always commit your changes into the [newstore-integrations](https://github.com/NewStore) repository so that we can maintain an up-to-date reference of what is deployed and have a record of the different versions. Since we don’t currently have a CI/CD pipeline, these two processes will be separate tasks. We can’t assume that what is in production is what is committed in the Git repository. Moreover, once you upload a template, the defaults will be overwritten, so consider using the preview API first. This is the general process for pushing out template changes: 1. Open a pull request with the desired changes. 2. Get the PR through the review process and get it merged to the master branch. 3. Checkout the master branch, and pull your merged changes (this ensures you don't lose anyone else's changes). 4. For each template that was changed: > [!TIP] > Note > > This is temporary; in the future, templates will be migrated from sandbox to staging, and staging to production, when code is pushed out to each environment). Otherwise, monitor any related code changes and upload the templates to staging and production once the code changes get deployed to those environments. 1. Upload the template to sandbox. 2. If your changes and any others that have been merged since the last upload to staging/production do not require any backend code changes, upload to staging and production. ## FAQ 1. Is the status of business event suppression visible through the API? No. 2. How can I be sure that my template is correct before I upload it? You can upload it first to staging or use the /preview method. 3. How do I get a preview for a subject? Use the /preview method and set it to HTML. 4. Can I use other filenames? Yes. 5. Can you delete a template? Templates cannot be deleted once they are uploaded. 6. Can I get back the defaults after uploading? No. 7. Can I have common includes across different locales? No. **Related topics** - [Customizing templates](/v1/docs/customizing-templates#templates) - [About customer documents and notifications](/v1/docs/customer-documents-and-notifications) - [Configuring documents for print in a store or warehouse](/v1/docs/configuring-documents-for-print-in-a-store-or-warehouse#config-notif-docs) The receipt given and sent to a customer for payment in a retail store. Some countries have instituted fiscal tax laws to ensure proper recording and collection of taxes during checkout via cash registers or point of sale systems. These regulations specify requirements for features, impermissible functions, receipts, reporting, and certification. For a list of countries where NewStore helps retailers to comply with fiscal regulations, See Adding fiscal signatures to receipts. When a retailer performs a transaction in a country that requires fiscalization, a digital signature may be required to be printed on the receipt to comply with Fiscal regulations. For more information, See Adding fiscal signatures to receipts.