- 
                Notifications
    
You must be signed in to change notification settings  - Fork 5.5k
 
feat: Add Shopify Get Order action #14858
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
          
     Closed
      
      
            GovardhaneNitin
  wants to merge
  2
  commits into
  PipedreamHQ:master
from
GovardhaneNitin:feature/shopify-get-order
  
      
      
   
      
    
  
     Closed
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            2 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { toSingleLineString } from "../../common/utils.mjs"; | ||
| 
     | 
||
| export default { | ||
| methods: { | ||
| /** | ||
| * Formats the order data response | ||
| * @param {object} order - The order object from Shopify | ||
| * @returns {object} - Formatted order data | ||
| */ | ||
| formatOrderData(order) { | ||
| return { | ||
| id: order.id, | ||
| order_number: order.order_number, | ||
| total_price: order.total_price, | ||
| created_at: order.created_at, | ||
| updated_at: order.updated_at, | ||
| fulfillment_status: order.fulfillment_status, | ||
| financial_status: order.financial_status, | ||
| customer: order.customer, | ||
| line_items: order.line_items, | ||
| shipping_address: order.shipping_address, | ||
| billing_address: order.billing_address, | ||
| }; | ||
| }, | ||
| }, | ||
| props: { | ||
| orderFields: { | ||
| type: "string[]", | ||
| label: "Order Fields", | ||
| description: toSingleLineString(` | ||
| Select which fields to include in the response. | ||
| If none selected, returns all available fields. | ||
| See Shopify Order API documentation for available fields: | ||
| https://shopify.dev/api/admin-graphql/2024-10/queries/order | ||
| `), | ||
                
      
                  GovardhaneNitin marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| optional: true, | ||
| }, | ||
| includeMetafields: { | ||
| type: "boolean", | ||
| label: "Include Metafields", | ||
| description: "Whether to include order metafields in the response", | ||
| optional: true, | ||
| default: false, | ||
| }, | ||
| includeCustomer: { | ||
| type: "boolean", | ||
| label: "Include Customer Details", | ||
| description: | ||
| "Whether to include detailed customer information in the response", | ||
| optional: true, | ||
| default: true, | ||
| }, | ||
| includeLineItems: { | ||
| type: "boolean", | ||
| label: "Include Line Items", | ||
| description: "Whether to include line items details in the response", | ||
| optional: true, | ||
| default: true, | ||
| }, | ||
| }, | ||
| }; | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import common from "./common.mjs"; | ||
| import app from "../../shopify.app.mjs"; | ||
| 
     | 
||
| export default { | ||
| ...common, // spread the common configurations | ||
| key: "shopify-get-order", | ||
| name: "Get Order", | ||
| description: "Retrieves a specific order from Shopify", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| orderId: { | ||
| type: "string", | ||
| label: "Order ID", | ||
| description: "The ID of the order to retrieve", | ||
| }, | ||
| ...common.props, // spread the common props | ||
| }, | ||
| async run({ $ }) { | ||
| const params = { | ||
| fields: this.orderFields, | ||
| include_metafields: this.includeMetafields, | ||
| include_customer: this.includeCustomer, | ||
| include_line_items: this.includeLineItems, | ||
| }; | ||
| 
     | 
||
| const response = await this.app.resourceAction( | ||
| "order", | ||
| "get", | ||
| params, | ||
| this.orderId | ||
| ); | ||
| 
     | 
||
| const formattedOrder = this.formatOrderData(response.result); | ||
| $.export("$summary", `Retrieved order ${this.orderId}`); | ||
| return formattedOrder; | ||
| }, | ||
                
      
                  GovardhaneNitin marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| }; | ||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.