For more details see how the Order Attributes extension works.
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.
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. Add Magento custom field input types to orders and quickly process collected data on the backend.
To configure the extension settings please go to Stores → Configuration → Amasty Extensions → Order Attributes.
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.
Send Attributes on Shipping Step — set 'Yes' to display order attributes on the shopping step. Set 'No' to prevent validation on Shipping Step (One Step Checkout better compatibility).
Newsletter Subscription - enable the option to display Newsletter Subscription option on the checkout via an order attribute. Set an attribute code of order attribute (Yes/No or Checkbox).
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.
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.
To add Magento 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.
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:
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.
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:
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.
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.
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.
If the Checkout Steps are different, you will not be able to set the dependency.
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.
When you add a custom attribute to Magento order, it will appear on the Orders Grid.
Additional order attributes data will be displayed on the Order info page.
Click Edit to modify custom attributes from the admin panel.
Include custom attributes in HTML and PDF printouts.
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.
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.
To get order attributes using API please look through these steps and methods:
This is how it works:
When you navigate to the second step of the checkout page or place an order (depending on the location of the attribute), the system creates an API query and sends it to the:
This class takes the obligatory parameters:
int $amastyCartId string $checkoutFormCode string $shippingMethodCode \Amasty\Orderattr\Api\Data\EntityDataInterface $entityData
Now the information about order attributes is recorded in database.
In order to pull the order attributes data out of DB, the following class was added:
1. Go to Swagger (http://.../swagger).
2. Find integrationAdminTokenServiceV1 and log in with admin rights.
3. Take the token in Response body.
4. Enter the token in a search string and click Apply.
5. Find a particular method (for example, amastyOrderattrEntityDataRepositoryV1)
6. Enter entityId (it's in amasty_order_attribute_entity table)
Done! The result will show up in Response body.
Besides, all of these manipulations can be carried out with Remote Access simply by sending a query to your website specifying url/rest/all/V1/amasty_orderattr/entityData?param=value, for example: