User Tools

Site Tools


Sidebar

magento_2:order_attributes

For more details see the Order Attributes extension page.

Order Attributes for Magento 2

Add an unlimited number of extra fields to your checkout page to easily collect and process additional order related data. Display all created order attributes on a handy backend grid to keep necessary information at hand.

  • Create order attributes of different types
  • Use flexible conditions for attribute fields display
  • Show additional attributes info on the order grid
  • Add custom attributes to emails and PDF documents
  • Show extra attributes depending on a selected shipping method

Due to flexible settings and intuitive interface, the Order Attributes for Magento 2 extension will help you easily fine tune the checkout page according to your requirements. Create as many additional order attributes as you need. Use various field input types and quickly process collected data on the backend.

General Settings

To configure the extension settings please go to Stores → Configuration → Amasty Extensions → Order Attributes.

Checkout Settings

Please, expand the Checkout Settings section:

Display Attribute Values in the Progress Sidebar — set the option to Yes if you want to display custom order attributes on the checkout progress bar;

Date Format — select the default date format for related attributes;

Time Format — choose the default time format for related attributes;

Include Order Attributes into Emails — enable this options to have the ability to include order attribute values into email.

PDF Documents

Then, expand the PDF Documents section:

Include Order Attributes into Shipment (packing slip) — enable this option to include the completed attributes into the shipping documentation;

Include Order Attributes into Invoice — enable this option to include the completed attributes into the invoice documentation.

Invoices and Shipments

Next, proceed to the Invoices and Shipments section:

Display Order Attributes on Invoices Grid — enable this option to display order attributes on the invoices grid;

Display Order Attributes on Invoices Create — enable this option to display order attributes when creating an invoice;

Display Order Attributes on Invoices View — enable this option to display order attributes when viewing an invoice;

Display Order Attributes on Shipments Grid — enable this option to display order attributes on the shipments grid;

Display Order Attributes on Shipments Create — enable this option to display order attributes when creating a new shipment;

Display Order Attributes on Shipments View — enable this option to display order attributes when viewing a shipment.

New Attribute Creation

To manage order attributes, please, go to Sales → Manage Order Attributes.

All created attributes will be displayed on the special grid. Click the Add New Order Attribute button to create an attribute or select the existing one to edit it.

Attribute Properties

Default Label — specify the attribute label that will be displayed on the frontend;

Attribute Code — specify the attribute code that will be used for internal needs;

Store View — select the store view for which the attribute will be available;

Customer Groups — select customer groups for which the attribute will be shown;

Frontend Input Type — choose the appropriate input type for an attribute. It’s possible to choose among various input types depending on your specific needs:

  • Text Field
  • Text Area
  • Date
  • Date With Time
  • Yes/No
  • Dropdown
  • Checkbox Group
  • Radiobuttons

For all input types except Dropdown, Checkbox Group, and Radiobuttons you can define the default value in the corresponding field.

For the Dropdown, Checkbox Group, and Radiobuttons input types you can add multiple options in the Manage Label/Options tab.

NOTE: after the attribute code and the catalog input type are specified and saved they can’t be changed.

Values Required — when the option is set to Yes customers won’t be able to leave this attribute field blank while getting registered;

Visible on frontend — enable this option to display the attribute on the frontend;

Visible on backend — enable this option to display the attribute in the backend;

Default Value — specify the value which will be preselected by default if necessary;

Input Validation — enable this option to check the filled in information for being valid before submission;

Minimum Text Length — specify the minimum text length for text-related attributes;

Maximum Text Length — specify the maximum text length for text-related attributes;

Input/Output Filter — this option is used for security reasons with the text and text-area input types. Choose the Strip HTML Tags option to exclude the code injections or the Escape HTML Entities option in order to screen the code injection. This option affects both frontend and backend sides.

Show On Checkout Step — specify at which checkout step the attribute should be displayed:

  • Shipping
  • Reviews & Payments

Display Sorting Order — set the sorting order for the attribute display on the frontend;

Save Entered Value For Future Checkout — if you set the option to Yes, the registered customers will need to fill in the field only once, after that the field will be automatically filled in (with the possibility to edit);

Show on Admin Grids — enable this option to display the attribute on the backend grids;

Include Into HTML Print-out — enable this option to include the attribute into the HTML print-outs;

Include Into PDF Documents — enable this option to include the attribute into the PDF documentation;

Include Into Transactional Emails — enable this option to include the attribute into the transactional emails.

Please, make sure that the Include Order Attributes into Emails option is enabled.

Then, switch to the Title, Tooltip, Options tab:

Manage Titles — specify the attribute title for each store view for which it is enabled;

Manage Tooltip — set a tooltip to display near the attribute on the frontend.

When done, please, proceed to the Shipping Methods tab:

Shipping Methods — specify particular shipping methods to show the extra attribute only to those customers who choose the specified methods.

Attribute Relations

To manage attribute relations please go to Sales → Order Attributes → Manage Attribute Relations.

On the Order Attribute Relations grid you'll see all created relations. It's possible to add an unlimited number of new relations and manage the already created one.

Relation Name — specify a relation name that will be used for internal needs only;

Parent Attribute — choose the attribute that will be a parent;

Attribute Options — select attribute values that will trigger the display of the dependent attributes;

Dependent Attributes — specify which attributes will be dependent. These attributes will be displayed only if a customer selects one of the specified values of a parent attribute.

Please, mind that you can create relations only for the following types of attributes:
  • Dropdown
  • Checkbox Group
  • Radio Buttons

Attributes Display in the Admin Panel

Order Grid

Display all custom order attributes on the Orders Grid.

Order View Page

Additional order attributes data will be displayed on the Order info page.

Click Edit to modify custom attributes from the admin panel.

HTML Printouts

Include custom attributes in HTML and PDF printouts.

Attributes on the Registration and Checkout Pages

See the example of custom order attributes with different input types (text fields, dropdowns, radio buttons, multiple checkboxes).

Display a handy calendar for the Date and Date and Time input types. The calendar appears once a customer clicks on the attribute field.

Also, the customers will be provided with the selected attributes on the checkout page.

Attribute Variables in Email Templates

With the module, you can include order attributes into the email templates.

Please, go to Marketing → Email Templates and hit the Add New Template button.

Next, select the required template from the Template dropdown menu and click the Load Template button. Then, specify the Template Name and proceed to the Template Content field. You can add the order attributes here. Click the Insert Variable button and choose the attribute you need to insert it in the template.

When done, click the Save Template button.

Additionally, you may need to set the new template as the main one for emails. Please, go to Stores → Configuration → Sales → Sales Emails. Then, expand the required tab and select the newly created template.

Compatibility with REST/SOAP API

To get order attributes using API please look through these steps and methods:

  • Order attributes should have “Include Into API” = Yes
  • To get order data you should be authorized as admin and have the API Authorization token
  • Use on of the methods below:
GET /V1/orders/
{id}
GET /V1/orders
amasty_order_attributes will be in amasty_order_attributes array and contains the array of the attributes. 
"attribute_code" - contains system attribute code;
"label" - contains attribute Title (can have specialchars)
"value" - contains attribute system value, like option ID or text
"value_output" - parsed value of attribute

For example:

(
.....
[entity_id] => 1
.....
[extension_attributes] => stdClass Object
(
........
[amasty_order_attributes] => Array
(
[0] => stdClass Object
(
[attribute_code] => amasty_code
[label] => Some Amasty
[value] => 215
[value_output] => amasty_option3
)
)
)

Or:

PUT /V1/orders/create
POST /V1/orders/
amasty_order_attributes should be in "extension_attributes" array and contain array of the attributes
"attribute_code" - contains system attribute code;
"value" - contains attribute system value, like option ID or text

For example:

"entity" => [
"entity_id" => 3,
"increment_id" => "000000004",
"store_id" => 1,
"extension_attributes" => [
"amasty_order_attributes" => [
[
"attribute_code" => "amasty_options",
"value" => value_id
],
[
"attribute_code" => "amasty_text",
"value" => 'test'
]
],
]
] 

Find out how to install the Order Attributes extension for Magento 2 via Composer.


Rate the user guide
 stars  from 5 votes (Details)
magento_2/order_attributes.txt · Last modified: 2018/08/27 08:23 by milosh