How to Get Shipment Tracking Numbers in Magento 2?
Summer Nguyen | 11-11-2024
The Most Popular Extension Builder for Magento 2
With a big catalog of 224+ extensions for your online store
In the world of ecommerce, providing customers with accurate and timely shipment tracking information is crucial for enhancing the overall buying experience. The Magento 2 platform offers a seamless solution to this challenge through its robust order management system and integration with various shipping carriers.
This guide will walk you through the step-by-step process of obtaining shipment tracking numbers in Magento 2. We will cover the configuration of shipping carriers, the integration of tracking information, and the various methods available for customers to access the tracking data.
Importance of Get the Tracking Number in Magento 2 Orders
There are several key reasons why getting the shipment tracking number from an order in Magento 2 is important:
Enhance Customer Experience:
Providing customers with the shipment tracking number allows them to monitor the status of their orders in real-time. Moreover, this transparency and visibility into the delivery process not only improves the overall customer experience but also enhances satisfaction. By giving customers the ability to track their orders, businesses can build trust and foster a stronger relationship with their clientele.
Improve Order Fulfillment Transparency:
The tracking number enables customers to track the progress of their orders, from dispatch to delivery. This transparency not only helps build trust and confidence in your ecommerce business but also enhances the overall customer experience by keeping them informed and assured about their purchases.
Streamline Customer Support:
When customers have access to the tracking number, they can independently check the status of their orders. This reduces the number of customer inquiries and support requests, thereby allowing your team to focus on other critical tasks. Additionally, this self-service capability enhances customer satisfaction by providing them with immediate and accurate information.
Optimize Logistics and Shipping:
Tracking numbers provide valuable data on delivery times and carrier performance. This information can help you optimize your shipping processes, identify areas for improvement, and negotiate better rates with carriers. By leveraging these insights, you can enhance efficiency, reduce costs, and ultimately provide a better service to your customers.
Facilitate Order Management:
The tracking number is a crucial piece of information integrated into the order management system in Magento 2. This integration allows you to easily access and reference the tracking details as needed for order fulfillment and customer support. As a result, it streamlines operations, ensuring that both your team and customers have quick and efficient access to shipment information.
Comply with Best Practices:
Providing tracking numbers is considered a best practice in the ecommerce industry, as it aligns with customer expectations and improves the overall shopping experience.
Shipping Extensions for Magento 2
All necessary extensions to perfect your shippingWays to Add Shipment Tracking Numbers in Magento 2
Method 1: Manual Addition via Magento Admin Panel
Manually adding a tracking number is straightforward and can be done directly from the Magento Admin panel, suitable for businesses with manageable order volumes:
-
Log in to the Admin Panel: Access your Magento 2 store backend by logging in.
-
Navigate to the Sales Section: Go to Sales > Orders.
-
Select the Order: Find the order to which you want to add a tracking number, and click View.
-
If the order already has a tracking number, click Track Order
- If the order hasn’t got a tracking number, you’ll need to add a new one. Navigate to Sales > Shipments
Click View
- Scroll down to the Shipping and Tracking Information section and fill out the Carrier, Title, and Tracking Number.
- Then, go back to Sales > Orders > view this order and click Track Order like we instructed above and the tracking order number will appear in this popup
To retrieve and manage shipment tracking numbers in Magento 2 through email notifications, follow these steps:
Navigate to the admin panel, and choose Sales > Shipments > View from the main menu.
To notify the customer of this comment via email, choose Send Tracking Information, the shipments will be sent.
Read more: How to Configure Magento Shipping Tracking in 2024
Method 2: Adding Tracking Numbers Programmatically
Create and use the AddTrackingNumber function when you want to add the tracking number (ex: event, plugin, etc.)
/**
* @throws LocalizedException
*/
public function AddTrackingNumber()
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create(\Magento\Sales\Model\Order::class)
->loadByAttribute('increment_id', '000000001');
//OR
$order = $objectManager->create(\Magento\Sales\Model\Order::class)
->load('1');
// Check if order has already shipped or can be shipped
if (!$order->canShip()) {
throw new \Magento\Framework\Exception\LocalizedException(
__('You can\'t create an shipment.')
);
}
// Initialize the order shipment object
$convertOrder = $objectManager->create(\Magento\Sales\Model\Convert\Order::class);
$shipment = $convertOrder->toShipment($order);
// Loop through order items
foreach ($order->getAllItems() as $orderItem) {
// Check if order item is virtual or has quantity to ship
if (!$orderItem->getQtyToShip() || $orderItem->getIsVirtual()) {
continue;
}
$qtyShipped = $orderItem->getQtyToShip();
// Create shipment item with qty
$shipmentItem = $convertOrder->itemToShipmentItem($orderItem)->setQty($qtyShipped);
// Add shipment item to shipment
$shipment->addItem($shipmentItem);
}
// Register shipment
$shipment->register();
$data = array(
'carrier_code' => 'ups',
'title' => 'United Parcel Service',
'number' => 'TORD23254WERZXd3', // Replace with your tracking number
);
$shipment->getOrder()->setIsInProcess(true);
try {
// Save created shipment and order
$track = $objectManager->create(\Magento\Sales\Model\Order\Shipment\TrackFactory::class)>create()>addData($data);
$shipment->addTrack($track)->save();
$shipment->save();
$shipment->getOrder()->save();
// Send email
$objectManager->create(\Magento\Shipping\Model\ShipmentNotifier::class)
->notify($shipment);
$shipment->save();
} catch (\Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(
__($e->getMessage())
);
}
}
Method 3: Using Extensions
If you run a store using Magento 2, handling lots of orders efficiently might seem tough. Normally, you would have to deal with each order individually to create invoices or shipments, which takes a lot of time and could lead to mistakes or delays, especially when you have many orders to process every day. Also, you can’t make invoices and shipments at the same time, which makes things even more complicated.
To solve these problems, it’s a good idea to use tools like the Magento 2 Mass Order Actions extension. This tool makes it much easier to manage orders by letting you add tracking numbers to several orders at once. The main advantages include:
-
Perform a single action for multiple orders.
-
Supports sliding pop ups.
-
Simultaneously create invoices and shipments.
Guide to Using Magento 2 Mass Order Actions to Add Tracking Numbers:
- Go to the menu in the Magento 2 admin panel and select Sales > Orders
- Click on the Actions dropdown menu
- Choose Create Shipment > Add Tracking Number
FAQs
How can I generate shipment tracking numbers in Magento 2?
To generate shipment tracking numbers in Magento 2, navigate to the Sales section in the Admin panel, select Orders, and choose the specific order you wish to ship. Click on Ship, and in the Shipping section, you can enter the tracking number provided by your carrier. Once saved, this tracking number will be associated with the order and can be accessed by both your team and the customer.
Can customers track their orders in Magento without logging in?
Yes, Magento offers a feature that enables customers to track their orders without needing to log in. By entering the required details, such as the order number and email address, on the “Track Order” page, customers can access the status and details of their orders. This convenient feature enhances the user experience by allowing order tracking without the necessity of creating an account or logging in.
How can customers find the tracking number for their orders in Magento 2?
Customers can find the tracking number for their orders in Magento 2 by checking the shipment confirmation email sent to them once the order is shipped. Additionally, if they have an account, they can log in to their account, go to the Orders section, and view the tracking number under the specific order details. For those who prefer not to log in, they can use the “Track Order” page by providing the order number and email address.
Conclusion
By deploying the appropriate method to retrieve and manage tracking numbers, businesses can improve their logistical efficiency, reduce customer service inquiries, and ultimately provide a smoother, more reliable shopping experience. Each method, from manual updates to using extensions, ensures that businesses of all sizes can adapt to their operational scale and type of products sold, keeping customers well-informed at every step of the delivery process.