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

fix: allow addresses to be AddressPayload or string on DraftOrder creation #1902

Merged
merged 21 commits into from
Oct 19, 2022

Conversation

kasperkristensen
Copy link
Contributor

@kasperkristensen kasperkristensen commented Jul 25, 2022

What

  • Allows shipping_addressand billing_addressbe either an AddressPayload or string as part of the create draft order endpoint props.

How

  • Implements the same patterns as used for the similar Cart endpoints.

Why
The endpoint was using an old pattern for switching between addresses being either ids or payloads, which resulted in billing_address not being added during the creation process if it was not passed as an id.

Also

  • Fixes the wrong payload types being used in js/react clients.

Closes CORE-720

@kasperkristensen kasperkristensen requested a review from a team as a code owner July 25, 2022 17:01
@changeset-bot
Copy link

changeset-bot bot commented Jul 25, 2022

⚠️ No Changeset found

Latest commit: 87338b6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kasperkristensen kasperkristensen changed the title fix: allow addresses to be AddressPayload or String on DraftOrder creation fix: allow addresses to be AddressPayload or string on DraftOrder creation Jul 25, 2022
@kasperkristensen kasperkristensen marked this pull request as draft July 26, 2022 06:02
@kasperkristensen kasperkristensen marked this pull request as ready for review July 26, 2022 09:59
Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

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

Nice catch!

I believe we should also allow you to pass address ids as payload when updating a draft order since we call CartService.update i.e. the payload to update-draft-order.ts should be:

@IsOptional()
  @IsType([AddressPayload, String])
  billing_address?: AddressPayload | string

  @IsOptional()
  @IsType([AddressPayload, String])
  shipping_address?: AddressPayload | string

What do you think?

@olivermrbl
Copy link
Contributor

Can I get you to merge in latest from develop and resolve conflicts?

@srindom
Copy link
Collaborator

srindom commented Oct 19, 2022

LGTM! Pending @olivermrbl for final approval 👍

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

Use correct payload type for create DraftOrder in medusa-js
3 participants