-
-
Notifications
You must be signed in to change notification settings - Fork 317
TrackingUrl #1147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey! I can definitely add that to ShopifySharp, but you should also be able to grab it using the GraphQL API and ShopifySharp's GraphService right now if you're using the latest version of ShopifySharp. Here's how you'd do it: var graphRequest = new GraphRequest()
{
Query =
"""
query getOrderWithTrackingUrls($orderId: ID!) {
order(id: $orderId) {
id
name
fulfillmentsCount {
count
}
fulfillments {
createdAt
deliveredAt
estimatedDeliveryAt
inTransitAt
updatedAt
displayStatus
id
requiresShipping
status
totalQuantity
trackingInfo {
company
number
url
}
}
}
}
""",
Variables = new Dictionary<string, object>
{
{"id", $"gid://shopify/Order/{shopifyOrderId}"},
}
};
var service = new GraphService(shopDomain, accessToken);
var result = await service.PostAsync<OrderWithTrackingUrlsQuery>(graphRequest); That graph query will pull in a Shopify order along with all of its fulfillments/tracking info. You can check out Shopify's API docs for more info on what info you can grab with the order and fulfillment queries. ShopifySharp supports them all! Deserializing the query aboveIf you use that query above, you need to create the public record OrderWithTrackingUrlsQuery(OrderWithTrackingUrls Order);
public record OrderWithTrackingUrls
{
public required string Id { get; set; }
public required string Name { get; set; }
public required OrderFulfillmentsCount FulfillmentsCount { get; set; }
public required IReadOnlyList<FulfillmentWithTrackingInfo> Fulfillments { get; set; }
}
public record OrderFulfillmentsCount(int Count);
public record FulfillmentWithTrackingInfo
{
public required DateTimeOffset CreatedAt { get; set; }
public required DateTimeOffset DeliveredAt { get; set; }
public required DateTimeOffset EstimatedDeliveryAt { get; set; }
public required DateTimeOffset InTransitAt { get; set; }
public required DateTimeOffset UpdatedAt { get; set; }
public required ShopifySharp.GraphQL.FulfillmentDisplayStatus DisplayStatus { get; set; }
public required string Id { get; set; }
public required bool RequiresShipping { get; set; }
public required ShopifySharp.GraphQL.FulfillmentStatus Status { get; set; }
public required int TotalQuantity { get; set; }
public required FulfillmentTrackingInfo TrackingInfo { get; set; }
}
public record FulfillmentTrackingInfo
{
public required string Company { get; set; }
public required string Number { get; set; }
public required string Url { get; set; }
} Or you could skip writing your own classes and use ShopifySharp's pre-generated classes in the public record OrderWithTrackingUrlsQuery(ShopifySharp.GraphQL.Order Order); All of that is explained in ShopifySharp's GraphQL docs. |
The shopify documentation mentions you can retrieve the TrackingUrl for orderlines, this would be very helpful for me.
Is there any way to retrieve this with the ShopifySharp package?
The text was updated successfully, but these errors were encountered: