Search code examples
shopware

How to use Order Custom Field value in Email Template?


I want to use a custom field's value of order in Order Confirmation Mail. Are custom fields assigned to order template? And how can you assign variables other then order's to the template?


Solution

  • You should have access to the order's custom fields in mail template by order.customFields['technical_name_of_custom_field']. Put real technical name of your custom field instead of technical_name_of_custom_field.

    In the email template by default you have access to following associations of Order

    $criteria
            ->addAssociation('deliveries.shippingMethod')
            ->addAssociation('deliveries.shippingOrderAddress.country')
            ->addAssociation('transactions.paymentMethod')
            ->addAssociation('lineItems')
            ->addAssociation('currency')
            ->addAssociation('addresses.country');
    

    and orderCustomer as well.