Order File Attachments for Magento 2
Lets customers upload files for a product before adding it to the cart, such as artwork, a reference image or a prescription. The files stay with the cart item and the order, and staff download them from the admin order view.
- Free
- Themes listed: Hyvä + Luma
composer require mage2kishan/module-order-attachments
- Package requirementsRead the source documentation
- Developer profileView Upwork profile
- Themes listedHyvä + Luma
- PHP versions listed8.1, 8.2, 8.3, 8.4
- Installation questionsDiscuss your store setup
What it does for your store
The main features, as listed in the module documentation.
-
Product Page Uploads
Drag and drop or browse, with a progress bar, image thumbnails and an optional note
-
Cart and Order Link
Files follow the cart line into checkout and are linked to the order item when the order is placed
-
Admin Grid and Order View
Manage Attachments grid and an Order Attachments section with a download link per file
-
Per-Product Control
Allow Order Attachments attribute: Use Config Setting, Yes or No
-
Private File Storage
Random file names under var/, sent only through controllers that check the owner
Installation
Example commands from the Magento root. Follow the package instructions and your staging and deployment process.
- 1Check the releaseMatch Magento, PHP, theme and dependency requirements.
- 2Install on stagingReview Composer changes and follow the package instructions.
- 3Configure and verifyUse the documented settings and test the affected features.
$ composer require mage2kishan/module-order-attachments $ bin/magento setup:upgrade $ bin/magento setup:di:compile $ bin/magento setup:static-content:deploy -f $ bin/magento cache:clean
Listed requirements
These are the details supplied in this listing. Confirm the selected release supports your Magento edition, PHP and storefront.
| Magento versions listed | 2.4.6, 2.4.7, 2.4.8 |
|---|---|
| PHP versions listed | 8.1, 8.2, 8.3, 8.4 |
| Themes listed | Hyvä, Luma |
| Composer package | mage2kishan/module-order-attachments |
Documentation
Product details and setup guidance. Check the package repository for release-specific instructions.
Overview
Order File Attachments for Magento 2 is a free, open source extension that lets customers upload files for a product before they add it to the cart, then keeps those files with the cart item and the order.
The upload widget sits on the product page and on the cart edit item page. Customers drop files or pick them with the file browser, see a progress bar and a thumbnail or file-type badge for each file, and can add a note. When they click Add to Cart, the files are linked to that cart line and listed under an Attachments entry in the cart, mini cart, checkout summary and order. When the order is placed, each file is linked to its order item.
Store staff download files from an Order Attachments section on the admin order view or from the Manage Attachments grid, which has thumbnails, keyword search and separate permissions for viewing and downloading. Customers find their files on the order page in My Account.
Each file is checked on the server for extension, content and size, saved under a random name in var/ outside the web root, and sent only to its owner. A product attribute turns uploads on or off per product, and the module ships Hyvä (Alpine.js) and Luma templates.
Best for:
- Print stores that need an artwork or logo file for each ordered item.
- Stores that ask for a reference image or document per line item, such as a prescription or a measurement sheet.
- Shops that want customer files in the admin order view instead of an email inbox.
What you get
What the module adds to the product page, cart, order and admin.
- Drag and drop upload widget with a progress bar, thumbnails and an optional customer note.
- Allowed extensions, a size limit per file (default 10 MB) and files per item (default 3).
- Allow Order Attachments product attribute with Use Config Setting, Yes or No.
- Manage Attachments admin grid plus Order Attachments sections on the admin and customer order views.
- Honeypot field and a limit of 20 uploads per 10 minutes per customer or session.
- Hyvä (Alpine.js) and Luma templates, MIT licensed, requires the free Panth Core module.
Magento 2 Order Attachments
Panth Order Attachments lets customers upload files for a specific product before they add it to the cart. The files stay linked to the cart line item, follow it through checkout and, once the order is placed, are attached to the order item. Customers see their files on the order page in their account; store staff download them from the admin order view or from a dedicated attachments grid. Typical uses are artwork for print products, prescriptions, reference images and documents that belong to one line item.
The module adds an upload widget to the product page (and to the cart "edit item" page), stores the files outside the web root under var/panth/order-attachments/, serves them only through access-checked controllers, records each file in its own database table and writes an "Attachments" line into the quote item options so the files are listed with the item in the cart, mini cart, checkout summary and order. Both the Hyvä theme (Alpine.js template) and the Luma theme (plain JavaScript template) are supported.
Product page: kishansavaliya.com/magento-2-order-attachments.html
Features
- Upload widget on the product page with drag and drop, file browser, per-file progress bar, thumbnails for images and a file-type badge for other files.
- Optional customer note that is saved with the uploaded files.
- Per-product control through the "Allow Order Attachments" product attribute (
panth_allow_order_attachment: Use Config Setting, Yes or No), plus an "Enable for All Products" switch that decides for every product left on "Use Config Setting". - Widget only shows on saleable products and only while the module is enabled.
- Server-side validation: form key, file extension (configurable allow list plus the executable-type deny list from
Panth\Core\Security\UploadExtensionPolicy; SVG, HTML, XML and script types are always refused), file content (the detected MIME type must match the extension, images must be readable images, HTML/script/PHP content is refused), file size and product permission. The templates apply the same extension, size and file-count limits before uploading. - Honeypot field and a rate limit of 20 uploads per 10 minutes (by customer ID for logged-in customers, by the uploads recorded in the session for guests).
- Files are stored under a random 40-character hex name in
var/panth/order-attachments/<product_id>/; the original file name is kept in the database and used for downloads. - Attachments are linked to the quote item after "Add to Cart" and re-linked (or unlinked) when the customer edits the item from the cart. Only attachments owned by the current visitor and uploaded for the same product are linked.
- On order placement an observer stores the order ID and order item ID on each attachment.
- "Order Attachments" section on the customer's order view page, grouped by product, with thumbnails, notes and download links.
- Lightbox for image attachments shown in the cart and mini cart on Hyvä; it closes with Escape or the Close button and returns focus to the thumbnail.
- "Order Attachments" section on the admin order view page with a download link per file.
- Admin grid ("Manage Attachments") with preview (image thumbnail or a file-type icon), file name, product link, order ID, customer email, status, upload date and a download action; type, size and note columns are available under Columns.
- Keyword search on the attachments grid (file name, customer email, file extension, order ID).
- Separate ACL resources for viewing the grid, downloading files and changing the configuration.
- Soft delete: removing a file before checkout sets its status to 0; files that belong to a placed order cannot be removed from the storefront.
Usage
Customer: product page and cart
- On a product that allows attachments, the customer drops files onto the widget or picks them with the file browser. Each file is uploaded immediately by an AJAX POST to
orderattachments/upload/saveand gets a database record with status 1 and no cart item yet. The widget shows a counter (for example "2/3"), a progress bar per file, an image thumbnail or an extension badge, and a text field for a note. - A file can be removed again before checkout (POST to
orderattachments/upload/delete); this sets the record status to 0. The file stays on disk.orderattachments/upload/listing?product_id=<id>returns the current visitor's active uploads for that product that are not yet linked to a cart item or order. - When the customer clicks "Add to Cart", the attachment IDs and the note are posted with the form. A plugin on
Magento\Checkout\Controller\Cart\Addlinks the records to the new quote item, stores the note on each record and adds an "Attachments" entry to the item's additional options. On Hyvä the entry is HTML with thumbnails (opened in a lightbox); on Luma it is a text list of file names. - Editing the item from the cart opens the product page with the current files preloaded. A plugin on
Magento\Checkout\Controller\Cart\UpdateItemOptionslinks newly added files, unlinks removed ones and rewrites the "Attachments" option. Submitting the edit with no files removes the option. - On order placement (
sales_model_service_quote_submit_success) the observerObserver\CopyAttachmentsToOrderwrites the order ID and order item ID to each active attachment of the ordered quote items.
Customer: account order view
My Account > My Orders > View Order shows an "Order Attachments" section below the order information, grouped by product, with image thumbnails, file type and size, the note and a download link (orderattachments/download/index?id=<attachment_id>).
Admin
- Sales > Orders > order view: an "Order Attachments" section (container
order_additional_info) lists file name with type and size, product (linked to the product edit page), uploaded by (customer email, "Customer #<id>" or "Guest"), note, date and a download link. - Admin menu Panth Infotech > Order Attachments > Manage Attachments: a UI grid over the
panth_order_attachmenttable with filters, column control, bookmarks and paging. Status shows "Active" (1) or "Deleted" (0). The Actions column offers Download (panth_orderattachments/attachment/download); image previews are loaded throughpanth_orderattachments/attachment/preview. - There is no delete action in the admin. Deleted (status 0) records and their files remain on disk.
Storage and access control
- New files are written to
var/panth/order-attachments/<product_id>/<random-hex>.<ext>, which is not served by the web server. The stored name comes from a cryptographically random generator; the original name is only kept in the database. Files uploaded by earlier versions topub/media/panth/order-attachments/are moved to the same relative path undervar/by the data patchMoveLegacyUploadsToPrivateStorageduringbin/magento setup:upgrade; the stored paths inpanth_order_attachmentare relative, so the download links keep working and the old direct media URLs return 404. Copies of those files held in database media storage (media_storage_file_storage) are also written tovar/and removed from the database. A file that cannot be moved is logged and left in place; the controllers still find it there (they look invar/first, thenpub/media/). The module itself does not build direct media URLs. - Database media storage: attachments are always kept on the local filesystem in
var/panth/order-attachments/and are never copied into database media storage, whatever "Media Storage" is set to. On a setup with several web nodes,var/panth/order-attachments/must be on storage shared by all nodes. - Ownership: an upload made by a logged-in customer belongs to that customer. A guest upload belongs to the session it was made in (its ID is kept in the checkout session) and to any session whose current quote contains the quote item it is linked to. An attachment with an order ID belongs to the customer who owns the order. For a guest order, the visitor who opened that order through Orders and Returns (the store's guest order lookup) can also view and download its attachments.
- Storefront download (
orderattachments/download/index) is allowed for the owner as described above; order attachments require the logged-in order owner. The file is always sent asapplication/octet-streamwithContent-Disposition: attachmentand the original file name. - Storefront thumbnail (
orderattachments/thumbnail/view) serves only JPEG, PNG, GIF, WebP and BMP files to the owner, withX-Content-Type-Options: nosniffand a sandboxing Content-Security-Policy. Everything else gets a 404. - Storefront upload and removal require a valid form key. Removal (
orderattachments/upload/delete) is refused for attachments that already have an order ID and for attachments not owned by the current visitor. - Admin download requires the ACL resource
Panth_OrderAttachments::attachment_download; admin preview requiresPanth_OrderAttachments::attachment_view. - The module does not add email templates. The "Attachments" item option is stored with the quote and order item and is rendered wherever Magento prints item options.
Templates that can be overridden
| Template | Used for |
|---|---|
view/frontend/templates/product/view/upload.phtml |
Upload widget on Hyvä (Alpine.js); applied through default_hyva.xml |
view/frontend/templates/luma/product/view/upload.phtml |
Upload widget on Luma (plain JavaScript); block product.order.attachments.upload, alias form_top inside product.info |
view/frontend/templates/lightbox.phtml |
Lightbox script added before the closing body tag on every storefront page while the module is enabled |
view/frontend/templates/order/view/attachments-frontend.phtml |
"Order Attachments" section on the customer order view |
view/adminhtml/templates/order/view/attachments.phtml |
"Order Attachments" section on the admin order view |
Color tokens for the widget are defined in etc/theme-config.json and registered with Panth\Core\ViewModel\ThemeConfig through etc/frontend/di.xml.
Documentation
USER_GUIDE.md is written for store administrators and covers installation, verifying the module is active, every configuration setting, enabling attachments on products, how customers use the widget in the product page, cart, cart edit and checkout, the admin order view and attachments grid, the customer order view, and troubleshooting.
Changelog
See CHANGELOG.md.
Compatibility
| Platform | Versions |
|---|---|
| Magento Open Source | 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.8 |
| Adobe Commerce | 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.8 |
| PHP | >=8.1 (from composer.json) |
| Themes | Hyvä (Alpine.js template) and Luma (plain JavaScript template) |
Composer constraints on Magento packages: magento/framework ^103.0, magento/module-catalog ^104.0, magento/module-sales ^103.0, magento/module-quote ^101.0, magento/module-checkout ^100.4, magento/module-eav ^102.0, magento/module-customer ^103.0, magento/module-store ^101.1, magento/module-media-storage ^100.4, magento/module-backend ^102.0, magento/module-ui ^101.2.
Requirements
- Magento Open Source or Adobe Commerce 2.4.4 to 2.4.8.
- PHP 8.1 or later.
mage2kishan/module-core^1.0.17 (modulePanth_Core). It provides the theme detection helper, the upload extension policy and the "Panth Infotech" admin menu that this module hooks into.- The Magento modules listed under Compatibility (all part of a standard Magento installation).
Installation
composer require mage2kishan/module-order-attachments
bin/magento module:enable Panth_Core Panth_OrderAttachments
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush
setup:di:compile is only needed when the store runs in production mode. The module ships no files under view/*/web, so no static content deployment is required for it.
Check that the module is enabled:
bin/magento module:status Panth_OrderAttachments
setup:upgrade creates the panth_order_attachment table and the "Allow Order Attachments" product attribute (attribute group "Order Attachments", global scope, default "Use Config Setting").
Configuration
Admin path: Stores > Configuration > Panth Extensions > Order Attachments. The same page is reachable from the admin menu entry Order Attachments > Configuration. All settings can be set at default, website and store view scope.
Section: "Order Attachments" (panth_orderattachments).
General Settings
| Setting | Default | What it does |
|---|---|---|
| Enable Order Attachments | Yes | Master switch. When No, the upload widget, the lightbox script and the upload endpoint are disabled. |
| Enable for All Products | No | Shown only when the module is enabled. Applies to products whose "Allow Order Attachments" attribute is "Use Config Setting": Yes shows the widget on them, No hides it. Products set to Yes always show the widget and products set to No never do. |
Config paths: panth_orderattachments/general/enabled, panth_orderattachments/general/enable_all_products.
Upload Settings
| Setting | Default | What it does |
|---|---|---|
| Allowed File Extensions | pdf,jpg,jpeg,png,gif,doc,docx,zip | Comma-separated list of extensions accepted by the uploader. Required. Extensions blocked by Panth\Core\Security\UploadExtensionPolicy (executable and script types) are rejected even if listed here. |
| Maximum File Size (MB) | 10 | Maximum size per file in megabytes. Required, whole number greater than zero. Checked in the browser and again on the server; the PHP upload_max_filesize and post_max_size limits still apply. |
| Maximum Files Per Item | 3 | Maximum number of files per cart line item. Required, whole number greater than zero. Enforced by the upload widget and again on the server when files are linked to a cart item (add to cart and cart item update); extra files are left unlinked and the customer sees a warning. |
Config paths: panth_orderattachments/upload/allowed_extensions, panth_orderattachments/upload/max_file_size, panth_orderattachments/upload/max_files_per_item.
Display Settings
| Setting | Default | What it does |
|---|---|---|
| Upload Button Label | Attach Files | Text shown on the upload button and as the widget heading. When empty, "Attach Files" is used. |
Config path: panth_orderattachments/display/upload_label. The "Attachments" item option is always written to the cart item and is shown wherever Magento prints item options (cart, mini cart, checkout summary, order).
Per-product setting
Catalog > Products > edit product > attribute group "Order Attachments" > "Allow Order Attachments" (Use Config Setting, Yes or No; default Use Config Setting). The attribute has global scope.
Uninstallation
bin/magento module:disable Panth_OrderAttachments
composer remove mage2kishan/module-order-attachments
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush
The following remain after removal and must be cleaned up by hand if no longer wanted: the panth_order_attachment table, the configuration rows under panth_orderattachments/ in core_config_data, the product attribute panth_allow_order_attachment, the uploaded files under var/panth/order-attachments/ and pub/media/panth/order-attachments/, and the "Attachments" entries stored in the additional options of existing quote and order items.
License
MIT License. Free and open source. See LICENSE in this repository.
Developer Notes
- Module name:
Panth_OrderAttachments; Composer package:mage2kishan/module-order-attachments; namespace:Panth\OrderAttachments. - Load sequence: after
Panth_Core,Magento_Catalog,Magento_Sales,Magento_Quote,Magento_Checkout. - Frontend route
orderattachments(controllersUpload/Save,Upload/Delete,Upload/Listing,Download/Index,Thumbnail/View). - Admin route
panth_orderattachments(controllersAdminhtml/Attachment/Index,Adminhtml/Attachment/Download,Adminhtml/Attachment/Preview). - Access and storage helpers:
Model\AttachmentAccess(ownership checks),Model\FileLocator(resolves a stored path invar/or, for older files,pub/media/),Model\Upload\FileValidator(extension, size and content checks),Model\LegacyUploadMigrator(moves files uploaded by earlier versions out ofpub/media/; used by the data patchSetup\Patch\Data\MoveLegacyUploadsToPrivateStorage). - Plugins (
etc/frontend/di.xml):Plugin\Cart\LinkAttachmentsAfterAddToCart(afterMagento\Checkout\Controller\Cart\Add::execute) andPlugin\Cart\UpdateAttachmentsOnCartUpdate(afterMagento\Checkout\Controller\Cart\UpdateItemOptions::execute). - Observer (
etc/events.xml, global scope):Observer\CopyAttachmentsToOrderonsales_model_service_quote_submit_success. - Model
Model\OrderAttachment(event prefixpanth_order_attachment), resource modelModel\ResourceModel\OrderAttachment, collectionModel\ResourceModel\OrderAttachment\Collection, grid collectionModel\ResourceModel\OrderAttachment\Grid\Collection(registered aspanth_orderattachments_listing_data_sourceinetc/di.xml). - Blocks:
Block\Product\View\Upload(widget;shouldShow(),getUploadConfig(),getExistingAttachments()),Block\Order\View\Attachments(customer order view),Block\Adminhtml\Order\View\Attachments(admin order view). - Helper
Helper\Configwraps all configuration paths. - UI grid
panth_orderattachments_listingwith column classesUi\Component\Listing\Column\Thumbnail,FileSize,ProductNameandActions. - Data patch
Setup\Patch\Data\AddAllowOrderAttachmentAttributecreates the product attributepanth_allow_order_attachment;Setup\Patch\Data\UseConfigForAllowOrderAttachmentturns it into a select with the source modelModel\Product\Attribute\Source\AllowOrderAttachment(empty value = Use Config Setting, 1 = Yes, 0 = No) and resets stored No values to Use Config Setting. - ACL resources:
Panth_OrderAttachments::config(configuration section),Panth_OrderAttachments::attachment_view(grid and menu),Panth_OrderAttachments::attachment_download(admin download). - Database table (
etc/db_schema.xml):panth_order_attachmentwith columnsattachment_id,quote_item_id,order_item_id,order_id,product_id,customer_id,customer_email,original_filename,stored_filename,file_path,file_size,mime_type,file_extension,customer_note,status,created_at,updated_at; indexes onquote_item_id,order_item_id,order_id,product_idandstatus. - Request parameters used by the templates:
order_attachment_ids[]andorder_attachment_noteon the add-to-cart and update-item forms;product_id,file,customer_noteand the honeypotoa_website_urlon the upload request.
| Module Category | Cart & Checkout |
|---|---|
| Best For | All Sizes |
Changelog
-
1.1.9, 2026-10-30
- Released under the MIT License: this module is free and open-source software.
-
1.1.8, 2026-10-06
- Guest orders: the attachment Download link and image thumbnails on the Orders and Returns order view now work for the guest who looked up the order, instead of sending the visitor to the home page. Access is checked against the store's guest order lookup, so other visitors still cannot open the files.
FAQ
How is this different from Magento's native "file" custom option?
Can customers upload multiple files per product?
Does it support Hyvä?
What file types are supported?
Where are files stored?
Can guests use Order Attachments?
Can the admin delete or replace an attachment after the order is placed?
Does it work with Adobe Commerce Cloud?
Does it support multi-store?
Is a REST API available?
Questions before you install?
Send me your composer.json and I will check for conflicts first. Free. Installation is +$45, custom work is quoted first.