From a403d999c4c07dd01967bb6f188cc5834167b185 Mon Sep 17 00:00:00 2001 From: seynadio <79858321+seynadio@users.noreply.github.com> Date: Mon, 14 Jul 2025 14:24:18 +0200 Subject: [PATCH] Enhance Shopify order queries with complete order data including line items - Updated GET_ORDER query to include comprehensive order information: - Complete line items with product and variant details - Shipping and billing addresses - Fulfillment tracking information - Payment transactions and refunds - Tax lines and discount allocations - All financial breakdowns (subtotal, shipping, tax, discounts) - Updated LIST_ORDERS query to include: - Line items with product information - Order status and fulfillment details - Customer and shipping information - Essential financial data This provides complete order data including all items, customer info, shipping details, and fulfillment tracking when retrieving orders. --- .../shopify_developer_app/common/queries.mjs | 586 +++++++++++++++++- 1 file changed, 553 insertions(+), 33 deletions(-) diff --git a/components/shopify_developer_app/common/queries.mjs b/components/shopify_developer_app/common/queries.mjs index 82ed65a7f914d..6ef9dc31ec770 100644 --- a/components/shopify_developer_app/common/queries.mjs +++ b/components/shopify_developer_app/common/queries.mjs @@ -1,45 +1,362 @@ const GET_ORDER = ` - query SuggestedRefund($id: ID!, $refundLineItems: [RefundLineItemInput!], $first: Int, $after: String) { + query GetOrder($id: ID!, $first: Int, $after: String) { order(id: $id) { id - metafields (first: $first, after: $after) { - nodes { - id - key - namespace - value - type + name + createdAt + updatedAt + processedAt + cancelledAt + cancelReason + closedAt + confirmed + note + tags + test + currencyCode + displayFinancialStatus + displayFulfillmentStatus + closed + requiresShipping + riskLevel + customerAcceptsMarketing + paymentGatewayNames + + totalPriceSet { + shopMoney { + amount + currencyCode } - pageInfo { - endCursor + presentmentMoney { + amount + currencyCode + } + } + + subtotalPriceSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + + currentTotalPriceSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + + totalDiscountsSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + + totalShippingPriceSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + + totalTaxSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode } } + customer { id displayName + firstName + lastName email phone - addresses (first: $first) { + note + acceptsMarketing + createdAt + updatedAt + verifiedEmail + tags + defaultAddress { + id address1 address2 city + province zip country + countryCodeV2 company + firstName + lastName + phone } } - totalPriceSet { - shopMoney { - amount - currencyCode + + billingAddress { + address1 + address2 + city + province + zip + country + countryCodeV2 + company + firstName + lastName + phone + } + + shippingAddress { + address1 + address2 + city + province + zip + country + countryCodeV2 + company + firstName + lastName + phone + } + + lineItems(first: 250) { + edges { + node { + id + title + quantity + variantTitle + vendor + fulfillmentStatus + fulfillableQuantity + refundableQuantity + requiresShipping + restockable + + originalUnitPriceSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + + discountedUnitPriceSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + + totalDiscountSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + + variant { + id + title + sku + barcode + weight + weightUnit + inventoryQuantity + price + compareAtPrice + availableForSale + image { + url + altText + } + } + + product { + id + title + handle + vendor + productType + tags + status + createdAt + updatedAt + images(first: 1) { + edges { + node { + url + altText + } + } + } + } + + taxLines { + title + rate + ratePercentage + priceSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + } + + discountAllocations { + allocatedAmountSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + discountApplication { + ... on DiscountCodeApplication { + code + applicable + } + ... on AutomaticDiscountApplication { + title + } + ... on ManualDiscountApplication { + title + description + } + } + } + } } - presentmentMoney { - amount - currencyCode + } + + shippingLines { + title + code + source + carrierIdentifier + requestedFulfillmentServiceId + deliveryCategory + originalPriceSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + discountedPriceSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + taxLines { + title + rate + ratePercentage + priceSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } } } - suggestedRefund(refundLineItems: $refundLineItems) { - subtotalSet { + + fulfillments { + id + status + displayStatus + createdAt + updatedAt + estimatedDeliveryAt + inTransitAt + deliveredAt + trackingCompany + trackingNumbers + trackingUrls + service { + serviceName + shippingMethods + } + fulfillmentLineItems(first: 250) { + edges { + node { + id + quantity + lineItem { + id + title + } + } + } + } + } + + transactions(first: 250) { + id + status + kind + gateway + test + createdAt + processedAt + amountSet { shopMoney { amount currencyCode @@ -49,11 +366,101 @@ const GET_ORDER = ` currencyCode } } - refundLineItems { - lineItem { - id + fees { + amount { + amount + currencyCode } - quantity + flatFee { + amount + currencyCode + } + rate + rateName + type + } + } + + refunds { + id + createdAt + note + totalRefundedSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + refundLineItems(first: 250) { + edges { + node { + id + quantity + restockType + location { + id + name + } + lineItem { + id + title + quantity + } + subtotalSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + totalTaxSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + } + } + } + transactions { + id + status + kind + gateway + amountSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + } + } + + metafields (first: $first, after: $after) { + nodes { + id + key + namespace + value + type + } + pageInfo { + endCursor } } } @@ -132,31 +539,143 @@ const LIST_ORDERS = ` orders(first: $first, after: $after, reverse: $reverse, query: $query) { nodes { id + name + createdAt updatedAt + processedAt + currencyCode + displayFinancialStatus + displayFulfillmentStatus + closed + confirmed + test + note + tags + totalPriceSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + subtotalPriceSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + totalTaxSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + totalShippingPriceSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } customer { id displayName + firstName + lastName email phone - addresses (first: $first) { + acceptsMarketing + defaultAddress { + id address1 address2 city + province zip country company } } - totalPriceSet { - shopMoney { - amount - currencyCode - } - presentmentMoney { - amount - currencyCode + shippingAddress { + address1 + address2 + city + province + zip + country + company + firstName + lastName + } + lineItems(first: 50) { + edges { + node { + id + title + quantity + variantTitle + vendor + fulfillmentStatus + originalUnitPriceSet { + shopMoney { + amount + currencyCode + } + presentmentMoney { + amount + currencyCode + } + } + variant { + id + title + sku + price + image { + url + altText + } + } + product { + id + title + handle + vendor + productType + images(first: 1) { + edges { + node { + url + altText + } + } + } + } + } } } + fulfillments { + id + status + displayStatus + trackingCompany + trackingNumbers + trackingUrls + } metafields (first: $first) { nodes { id @@ -169,6 +688,7 @@ const LIST_ORDERS = ` } pageInfo { endCursor + hasNextPage } } }