How To

How to Get Shipment Information Using SOAP API in Magento 2

Hello Magento Friends,

Hope you are doing great! Again I am up with a new tutorial blog on SOAP API for Magento 2. This time it is about fetching shipment details through SOAP API in Magento 2.

SOAP API helps to build connections between your Magento platform and external systems. Shipping information of the order is to be given to the courier service provider for delivery. You can Create Shipment Programmatically or Create Shipment using API in Magento 2. So, when you need shipping information outside the Magento system you can fetch it using SOAP API.

Let’s get moving,

Steps to Get Shipment Information Using SOAP API in Magento 2:

Step 1: Create a getshipmentinfo.php file anywhere and add the following code:

<?php
$request = new SoapClient("http://yourdomain/index.php/soap/?wsdl&services=integrationAdminTokenServiceV1", array("soap_version" => SOAP_1_2));

$token = $request->integrationAdminTokenServiceV1CreateAdminAccessToken(array("username" => "admin", "password" => "admin123"));

$request = new SoapClient(
    'http://yourdomain/index.php/soap/default?wsdl&services=salesShipmentRepositoryV1',
    array(
        'soap_version' => SOAP_1_2,
        'stream_context' => stream_context_create(array(
            'http' => array('header' => 'Authorization: Bearer ' . $token->result)
        ))
    )
);
try
{
    $response = $request->salesShipmentRepositoryV1Get(array('id' => 4));
}
catch (Exception $e)
{
    echo "<pre>";
    print_r($e->getMessage());
    exit;
}
echo "<pre>";
print_r($response);
?>

Conclusion:

Accordingly, you can get shipment information using SOAP API in Magento 2. If you have any doubts, share with me via the comment section. 

Happy Coding!

Click to rate this post!
[Total: 6 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

Recent Posts

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

1 day ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

1 day ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

2 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

3 days ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

5 days ago

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

5 days ago