Cookies setting

Cookies help us enhance your experience on our site by storing information about your preferences and interactions. You can customize your cookie settings by choosing which cookies to allow. Please note that disabling certain cookies might impact the functionality and features of our services, such as personalized content and suggestions. Cookie Policy

Cookie Policy
Essential cookies

These cookies are strictly necessary for the site to work and may not be disabled.

Information
Always enabled
Advertising cookies

Advertising cookies deliver ads relevant to your interests, limit ad frequency, and measure ad effectiveness.

Information
Analytics cookies

Analytics cookies collect information and report website usage statistics without personally identifying individual visitors to Google.

Information
mageplaza.com

How to add Order Attributes to PDF Order Template

Vinh Jacker | 09-17-2024

How to add Order Attributes to PDF Order Template

Note: You need to install Mageplaza PDF Invoice extension to use this feature of Order Attributes extension.

How to add Order Attributes to PDF Order Template

Step 1: Take Order Attribute code

  • Admins need to access Sales > Order Attributes > Manage Attributes, edit Order Attribute that they want to add to the email. Copy Attribute code of Order Attribute

order attribute

Step 2: Create PDF Order Template

  • Go to Stores > PDF Invoice > Manage Templates, choose Add New Order Template (or edit the template if you want)

order attribute2

  • Load Template of New Order template

order attribute1

  • Insert Order Attribute to the template on any positions that you want. Please follow the structure below:

    • For Input Type = Text, Text Area, Date, Content, Media Image, Single File Attachment
{{depend order.getOrderAttrText1()}}
     <p>{{var order.getOrderAttrText1Label()}} {{var order.getOrderAttrText1() |raw}}</p>
{{/depend}}

  • For Input Type = Yes/No, Dropdown, Multiple Select, Single-select with Image, Multiple-select with Image
{{depend order.getOrderAttrText1Option()}}
     <p>{{var order.getOrderAttrText1Label()}} {{var order.getOrderAttrText1Option() |raw}}</p>
{{/depend}}

  • For Single File Attachment, when inserting this code, the attachment will show in the email under the link format. Customers can click on the link to download this file.
{{depend order.getOrderAttrText1()}}
     <p>{{var order.getOrderAttrText1Label()}}: <a target="_blank" href="{{var order.getOrderAttrText1Url()}}">{{var order.getOrderAttrText1Name()}}</a></p>
{{/depend}}
  • For Media Image, when inserting this code, Media Image is displayed in the email. Customers can click on the link to open the image in a new tab.
{{depend order.getOrderAttrText1()}}
     <p>{{var order.getOrderAttrText1Label()}}: <a target="_blank" href="{{var order.getOrderAttrText1Url()}}"><img title="View Full Size" alt="{{var order.getOrderAttrText1Name()}}" src="{{var order.getOrderAttrText1Url()}}" /></a></p>
{{/depend}}

In case: Depend tag is used to check whether if the attribute is empty or not, if yes, it will not show the HTML code. OrderAttrText1 is an Attribute code that is capitalized every first letter.

For example:

  • For Order Attribute as Input = Date, attribute code is delivery_time, so you need to add the following code:
{{depend order.getDeliveryTime()}}
   <p>{{var order.getDeliveryTimeLabel()}} {{var order.getDeliveryTime() |raw}}</p>
{{/depend}}

  • For Order Attribute as Input = Dropdown, attribute code is choose_gift_wrap, so you need to add the following code:
{{depend order.getChooseGiftWrapOption()}}
   <p>{{var order.getChooseGiftWrapLabel()}} {{var order.getChooseGiftWrapOption() |raw}}</p>
{{/depend}}
  • For Order Attribute as input = Single File Attachment, attribute code is attachment, so you need to add the following code:
{{depend order.getAttachment()}}
     <p>{{var order.getAttachmentLabel()}}: <a target="_blank" href="{{var order.getAttachmentUrl()}}">{{var order.getAttachmentName()}}</a></p>
{{/depend}}
  • For Order Attribute as input = Media Image, attibute code is media_image, so you need to add the following code:
{{depend order.getMediaImage()}}
     <p>{{var order.getMediaImageLabel()}}: <a target="_blank" href="{{var order.getMediaImageUrl()}}"><img title="View Full Size" alt="{{var order.getMediaImageName()}}" src="{{var order.getMediaImageUrl()}}" /></a></p>
{{/depend}}

Step 3: Apply PDF Order Template that you have just created

  • Go to Stores > Settings > Configuration, choose Mageplaza > PDF Invoice
  • In the Order section, choose PDF Order Template you just created:

order attribute3

Step 4: Check

  • Place the Order on the Frontend
  • Check the email that the system has just sent to customers

order attribute4

x
    Jacker

    With over a decade of experience crafting innovative tech solutions for ecommerce businesses built on Magento, Jacker is the mastermind behind our secure and well-functioned extensions. With his expertise in building user-friendly interfaces and robust back-end systems, Mageplaza was able to deliver exceptional Magento solutions and services for over 122K+ customers around the world.



    Related Post

    Website Support
    & Maintenance Services

    Make sure your store is not only in good shape but also thriving with a professional team yet at an affordable price.

    Get Started
    mageplaza services