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

Add support for orders custom data on transactions CSV #500

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

Betree
Copy link
Member

@Betree Betree commented Oct 9, 2023

No description provided.

@@ -273,6 +274,7 @@ const csvMapping = {
merchantId: (t) => get(t, 'merchantId'),
orderMemo: (t) => get(t, 'order.memo'),
orderProcessedDate: (t) => (t.order?.processedAt ? moment.utc(t.order.processedAt).format('YYYY-MM-DD') : ''),
orderCustomData: (t) => get(t, 'order.customData'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't custom data an object?

Copy link
Member Author

@Betree Betree Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an object. In my tests json2csv properly stringified the value

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so the CSV value will be a stringified JSON. Is this something that we are already doing elsewhere?

What is the use case, will that help people achieve what they want? Given than they may have to parse the JSON to extract the data?

Not blocking but just to understand.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's from https://opencollective.slack.com/archives/C6JTTA4SK/p1696831552748589?thread_ts=1686331488.222289&cid=C6JTTA4SK, the data they're getting from this is a phone number collected via a custom field in the contribution flow.

The alternative would be to explode the customData object and have one column per field:

  • Input: { phone: '0123456789', age: 43 }
  • Output:
Custom data -> phone customData -> age
0123456789 43

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok let's keep it as stringified JSON.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If needed, we could implement a separate parameter to achieve that behavior of splitting into columns in the future

@Betree Betree merged commit a37b7ca into main Oct 10, 2023
2 of 3 checks passed
@Betree Betree deleted the enhancement/export-csv-custom-data branch October 10, 2023 09:46
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 this pull request may close these issues.

2 participants