Add Tracking Number To Shipment Programmatically
Do you have an order shipment and you want to add a tracking number to it programmatically? Let's see how you can do that!
This is our first post in 2020 and before we start, we would like to wish you a Happy New Year! This year we will continue with our blog posts about how you to develop things in Magento 2.
In this post we will create a function which you can call and add a tracking number to a shipment. The function below takes as parameter the order shipment id and adds a tracking number for the custom carrier. In our example the values needed to add a tracking number are fixed in the function, but you can change that and make it dynamically by passing them as parameters to the function together with the shipment id. So our function addTrack will look like below.
Feel free to share this post and ask your questions in the comments below.
Till next time!