Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Accept User input for Fulfillment type in PDP & Fulfillment Grouping #45

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

sujithvn
Copy link

Resolves #MCOSS-52
Impact: breaking
Type: feature

Issue

Currently "shipping" is the only fulfillment group in the cart/order and the current logic is to add the items into the the first matching group (comparing supported fulfillment type and existing groups).

Solution

Code fixed to pass all the supported fulfillment types into the grouping logic. This ensures that all the required groups based on the types can be created. Additionally code changes made to add the item to all the matching groups (earlier it was just the first matching).

In case the UI provided the optional field of selected fulfillment type (assuming the user selected it in the PDP page), then this is considered and the item is added only to the selected group.

Breaking changes

As the item is added to all the supported groups, we have to explicitly make the user select one of the group during the checkout and remove the items from the remaining groups. In case the user has already selected the fulfillment type in previous screens and provided the selectedFulfillmentType in API, then the item is already grouped under a single one.

Testing

  1. Tested by invoking the mutation addCartItems with and without "selectedFulfillmentType" and the results had the group created separately
    Sample
mutation addCartItem {
    addCartItems(input: {
      items: [
                {
                    price: {
                        amount: 19.99,
                        currencyCode: "USD"
                    },
                    productConfiguration: {
                        productId: "cmVhY3Rpb24vcHJvZHVjdDpzdzN3Z1BNWEdGV2NLTHo0aQ==",
                        productVariantId: "cmVhY3Rpb24vcHJvZHVjdDptN253OW1SOFlFcUFoSjRZNQ=="
                    },
                    quantity: 1,
                     selectedFulfillmentType: "pickup"
                }
            ],
            cartToken: "GgoC2nR8vW7NXq-c7r5gxBy4hbyNqtTQEk1-q2iG5HK",
            cartId: "cmVhY3Rpb24vY2FydDp3c2RIcVFNMzRwYkE0ZnlybQ=="
    }) {
      cart  {
        checkout {
          fulfillmentGroups {
            _id
            type
            items {
              title
              selectedFulfillmentType
              quantity
            }            
          }
        }
      }
    }
  }

@sujithvn sujithvn requested a review from brent-hoover July 11, 2022 07:48
@sujithvn sujithvn requested a review from vanpho93 July 18, 2022 08:18
@@ -23,37 +49,40 @@ export default function updateCartFulfillmentGroups(context, cart) {
// Every time the cart is updated, create any missing fulfillment groups as necessary.
// We need one group per type per shop, containing only the items from that shop.
// Also make sure that every item is assigned to a fulfillment group.
// Update: Refer MCOSS-52:
Copy link
Member

Choose a reason for hiding this comment

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

Unit test for this would be great.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants