{"id":19622133,"url":"https://github.com/commercetools/orders-update","last_synced_at":"2025-04-28T03:32:23.114Z","repository":{"id":14391732,"uuid":"74683414","full_name":"commercetools/orders-update","owner":"commercetools","description":"A library that helps with updating orders into the commercetools platform.","archived":false,"fork":false,"pushed_at":"2023-07-11T19:27:47.000Z","size":858,"stargazers_count":1,"open_issues_count":10,"forks_count":1,"subscribers_count":79,"default_branch":"master","last_synced_at":"2025-04-20T15:17:58.830Z","etag":null,"topics":["audit-import-export"],"latest_commit_sha":null,"homepage":"https://npmjs.com/@commercetools/orders-update","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/commercetools.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"contributing.md","funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-24T15:06:48.000Z","updated_at":"2022-12-10T22:56:15.000Z","dependencies_parsed_at":"2024-11-11T11:32:14.124Z","dependency_job_id":"68e9ab65-4ffb-4d8e-bd70-ed4c12799ca9","html_url":"https://github.com/commercetools/orders-update","commit_stats":{"total_commits":27,"total_committers":10,"mean_commits":2.7,"dds":0.7777777777777778,"last_synced_commit":"cdd1a62653699fc0afe25a1b666dec920ed3fdd3"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commercetools%2Forders-update","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commercetools%2Forders-update/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commercetools%2Forders-update/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commercetools%2Forders-update/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commercetools","download_url":"https://codeload.github.com/commercetools/orders-update/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251246334,"owners_count":21558762,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audit-import-export"],"created_at":"2024-11-11T11:26:08.876Z","updated_at":"2025-04-28T03:32:22.394Z","avatar_url":"https://github.com/commercetools.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![commercetools logo][commercetools-icon]][commercetools]\n\n# Orders Update\n[![Travis Build Status][travis-icon]][travis]\n[![Codecov Coverage Status][codecov-icon]][codecov]\n[![David Dependencies Status][david-icon]][david]\n[![David devDependencies Status][david-dev-icon]][david-dev]\n\nA library that helps with updating [orders](https://dev.commercetools.com/http-api-projects-orders.html) into the [commercetools] platform.\n\n## Supported order fields\n- customLineItems\n- lineItems\n- syncInfo\n- returnInfo\n- shippingInfo.deliveries\n\n## Usage\n\n### CLI\n\nYou can use the orders update from the command line using [`sphere-node-cli`](https://github.com/sphereio/sphere-node-cli).\nIn order for the CLI to update orders, the file to update from must be JSON and follow the this structure:\n```\n{\n  \"orders\": [\n    \u003corder\u003e,\n    \u003corder\u003e,\n    ...\n  ]\n}\n```\n\nTo update lineItems/customLineItems status the order object have to follow this format\n```\n{\n  orderNumber: 1234567,\n  lineItems: [{\n    state: [{\n      fromState: 'statekey',\n      toState: 'statekey',\n      quantity: 20, // The number of quantity you want to migrate from the a state to another.\n      _fromStateQty: 100 // The quantity in the 'fromState' before the update. More information about why this is necessary [here](https://github.com/commercetools/orders-update/issues/11)\n    }]\n  }]\n}\n\n```\nThen you can use this file using the cli:\n```\nsphere-node-cli -t order -p my-project-key -f ./orders.json\n```\n\nWhen updating `returnInfo`, all items are compared against existing return info items. If there is a matching returnInfo item (matched by keys `returnTrackingId` and `returnDate`) script goes through returnItems and sets new `shipmentState` or `paymentState` if they differ from old values. If returnInfo item is not found it is inserted as a new item. \n### Direct usage\n\nIf you want more control, you can also use this library directly in JavaScript. To do this you first need to install it:\n```\nnpm install @commercetools/orders-update --save\n```\nThen you can use it to update an order like so:\n```\nconst fs = require('fs');\nconst OrdersUpdate = require('orders-update');\n\nconst ordersUpdate = new OrdersUpdate({\n  config: {\n    project_key: '',\n    client_id: '',\n    client_secret: '',\n  },\n});\n\nconst orderData = JSON.parse(fs.readFileSync('order.json'));\n\nordersUpdate.processOrder(orderData)\n  .then(() =\u003e {\n    // look at the summary\n    console.info(ordersUpdate.summary);\n\n    // {\n    //   errors: [...],\n    //   inserted: [...],\n    //   successfulImports: 1\n    // }\n  })\n  .catch(console.error);\n```\n\n## Configuration\n`OrdersUpdate` accepts one object as an argument:\n- API client config (_required_)\n  - See the [SDK documentation](http://sphereio.github.io/sphere-node-sdk/classes/SphereClient.html) for more information.\n- Logger takes object with four functions (_optional_)\n  - error\n  - warn\n  - info\n  - verbose\n\n## Contributing\nSee [contributing.md](contributing.md) for info on contributing.\n\n[commercetools]: https://commercetools.com/\n[commercetools-icon]: https://cdn.rawgit.com/commercetools/press-kit/master/PNG/72DPI/CT%20logo%20horizontal%20RGB%2072dpi.png\n[travis]: https://travis-ci.org/commercetools/orders-update\n[travis-icon]: https://img.shields.io/travis/commercetools/orders-update/master.svg?style=flat-square\n[codecov]: https://codecov.io/gh/commercetools/orders-update\n[codecov-icon]: https://img.shields.io/codecov/c/github/commercetools/orders-update.svg?style=flat-square\n[david]: https://david-dm.org/commercetools/orders-update\n[david-icon]: https://img.shields.io/david/commercetools/orders-update.svg?style=flat-square\n[david-dev]: https://david-dm.org/commercetools/orders-update?type=dev\n[david-dev-icon]: https://img.shields.io/david/dev/commercetools/orders-update.svg?style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommercetools%2Forders-update","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommercetools%2Forders-update","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommercetools%2Forders-update/lists"}