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

Feat(api): add attachments #1304

Merged
merged 5 commits into from
May 23, 2022
Merged

Feat(api): add attachments #1304

merged 5 commits into from
May 23, 2022

Conversation

icazevedo
Copy link
Contributor

@icazevedo icazevedo commented May 17, 2022

What's the purpose of this pull request?

This PR adds support for attachments on FastStore API. Attachments are a way to customize a product. If a product is added to the cart with a different attachment, a new offer should be created for it. An offer should be considered the same as another one if and only if the attachments (and its value) are also equal.

How it works?

The attachments are included under the additionalProperty field, where they can be filtered through valueReference comparison. They are received in the same format they're sent.

How to test it?

JSON variables of the graphql query to the validateCart mutation:

{
  "cart": {
    "order": {
      "orderNumber": "911b0ceef77e4b98b9ca250a5d2fab2b",
      "acceptedOffer": [
        {
          "price": 602.78,
          "listPrice": 834.97,
          "seller": {
            "identifier": "1"
          },
          "quantity": 1,
          "itemOffered": {
            "sku": "2000586",
            "image": [
              {
                "url": "http://storeframework.vtexassets.com/arquivos/ids/177382/assumenda.jpg?v=637753139967300000",
                "alternateName": "hic"
              }
            ],
            "name": "Bells add-ons",
            "additionalProperty": [
              {
                "name": "1-3-lines",
                "value": "{\"Line 1\":\"1\",\"Line 2\":\"2\",\"Line 3\":\"3\"}",
                "valueReference": "ATTACHMENT"
              }
            ]
          }
        }
      ]
    }
  }
}

Starters Deploy Preview

https://github.com/vtex-sites/nextjs.store/pull/47
vtex-sites/gatsby.store#53

@vercel
Copy link

vercel bot commented May 17, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
faststore ✅ Ready (Inspect) Visit Preview May 18, 2022 at 10:51PM (UTC)

* feat: validate cart with attachments

* feat: improve get id

* Add attachment type

Co-authored-by: Ícaro Azevedo <icazevedo10@gmail.com>
@codesandbox-ci
Copy link

codesandbox-ci bot commented May 17, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 4134943:

Sandbox Source
Store UI Typescript Configuration

@emersonlaurentino emersonlaurentino marked this pull request as ready for review May 18, 2022 16:16
@emersonlaurentino emersonlaurentino requested a review from a team as a code owner May 18, 2022 16:16
Comment on lines +9 to +10
parseValue: toObjectOrString,
serialize: stringify,
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't get it, does the ouptut will be always a string, either a string or a stringified object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is always a string, but it can be a regular string eg. "hello world" or and stringified object "{"key": "value"}"

@igorbrasileiro
Copy link
Contributor

@icazevedo great job, I left some comments that may affect this PR.

@icazevedo icazevedo merged commit 978a642 into main May 23, 2022
@icazevedo icazevedo deleted the feat/add-attachments branch May 23, 2022 13:34
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.

3 participants