Skip to content
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

Integrate custom order item options w/ Sales Order Item fields #52

Open
batonac opened this issue Jun 15, 2022 · 2 comments · May be fixed by #57
Open

Integrate custom order item options w/ Sales Order Item fields #52

batonac opened this issue Jun 15, 2022 · 2 comments · May be fixed by #57

Comments

@batonac
Copy link

batonac commented Jun 15, 2022

I need to import order item metadata/options from ShipStation orders with custom fields into ERPNext.

For example, I'd like to import the following "options" from the ShipStation API (excerpt from the ShipStation Get Order API):

... 
   "items": [
        {
            "orderItemId": 142302926,
            "lineItemKey": "9991",
            "sku": "custom-design",
            "name": "Upload Your Own Design",
           ...
            "options": [
                {
                    "name": "Design File",
                    "value": "EggShell_Stripe_06_13_22.jpg"
                },
                {
                    "name": "Design Scale (in inches)",
                    "value": "2 x 2"
                },
                {
                    "name": "Fabric",
                    "value": "Organic Cotton Interlock (American Milled)"
                },
                {
                    "name": "Size",
                    "value": "Fat Quarter (21\"x18\")"
                },
                {
                    "name": "Price Per Fat Quarter",
                    "value": "Qty: 1, Price: $13.00"
                }
            ],
            "productId": 1683943,
            "fulfillmentSku": null,
            "adjustment": false,
            "upc": null,
            "createDate": "2022-06-13T18:35:36.187",
            "modifyDate": "2022-06-13T18:35:36.187"
        },
...

Each of these fields ("Design File", "Design Scale", etc) would have a corresponding custom field in the Sales Order Items table to record this data from ShipStation.

I'm assuming this could be accomplished with the update_shipstation_order_before_submit hook, but I'm a bit confused by the code since the item key syntax used in shipstation_integration/shipstation_integration/orders.py doesn't correspond to the key syntax of the ShipStation API. For example, the key for the Order Item ID from the API is orderItemId but the key used in orders.py is item.order_item_id. This leaves me feeling unsure how to reference values in the underlying array.

I'm glad to pay for commercial development around this, and sent a corresponding request to Parsimony, but thought I'd mention it here as well in case this is rudimentary to solve...

In the end, I suppose this is part support request, part feature request. It's vital, in some scenarios, to have some way for this order item metadata to flow through. Baking support for this into this app, with some kind of corresponding lookup/match table in the Shipstation Settings, would be swell. I'm glad to do some sponsoring here either way.

@Alchez
Copy link
Contributor

Alchez commented Jun 15, 2022

@batonac, the keys are actually changed to a Python format (snake_case instead of the API's camelCase) in the client library we use in the app. It's more of a developer-friendly feature than a functional change, so you shouldn't see any problems parsing data from the Shipstation API object.

Regarding the metadata feature, it makes sense to pull in those fields. Currently the before_submit hook will only pull the first hook it finds, but we can make a change so that it'll loop through every hook looking for changes. I'm currently busy on another project, but a pull request with any changes is welcome.

By a lookup table, do you mean a reference to all the custom fields imported from a particular store?

@batonac
Copy link
Author

batonac commented Jun 15, 2022

@Alchez That's great to know, about the keys.

Yes, by lookup table, I'm thinking of a table in the ShipStation Settings that allows for pairing ShipStation option keys with custom fields in the ERP:

ShipStation Option Name Order Item Field
Design File shipstation_design_file
Design Scale shipstation_design_scale
Size shipstation_size

@batonac batonac linked a pull request Sep 21, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants