This will be a new product kind namely: comboWithCustomization
.
This kind of product is useful for cases where a product combo consist of items that are customizable by the customer. A good example is a Mcdonalds combo lets say the big mac combo. The burger is set, but the fries is customizable where the customer can opt for large fries, similar for drink customer can not only choose drink but can also opt for large drink.
The resulting order line item tree should be like the following:
- Customized Big Mac Combo x 1 ------------- $10.99
- Big Mac Combo x 1 -------- $9.99 (Base combo)
- Large Fries x 1 ---------- $1.00 (Customizable item)
- Large Drink -------------- $1.00 (Customizable item)
- Coke x 1 ----------------- $0.00 (Customizable item)
We will call the item that is added under the combo as customizable item, each customizable item is actually a product, for now we only support simple product as customizable item.
In order to achieve this, a new resource ProductCustomizationGroup
and ProductCustomizationGroupMembership
need to be created with structure like the following:
{
"id": "39bc17e7-cd32-4f2b-9711-ffe71f6d9f39"
"type": "ProductCustomizationGroup",
"attributes": {
"name": "Drink",
"maxiumSelect": 3, // Indicates customer cannot select more than 3 products from this group
"minimumSelect": 1 // Indicates customer must at least select 1 products from this group
},
"relationships": {
"product": {
"data": { "id": "39bc17e7-cd32-4f2b-9711-ffe71f6d9f37", "type": "Product" }
}
}
}
{
"type": "ProductCustomizationGroupMembership",
"attributes": {
"sortIndex": 1000,
"default": false, // Indicates whether this is the default selected for the group
"minimumOrderQuantity": 1,
"maximumOrderQuantity": 2
},
"relationships": {
"product": {
"data": { "id": "b881ee15-5a36-4a94-b8d8-7f2ec631486b", "type": "Product" }
},
"price": {
"data": { "id": "31abfc62-0099-4088-8e60-915e87a578b2", "type": "Price" }
}
}
}
The product that is associated to the ProductCustomizationGroupMembership
is what we called the customizable item. The relationsips between the resources are as follow:
- Each product combo with customization has many customization group
- Each product combo with customization has many prices which act as the base price for the combo
- Each customization group has many membership
- Each customization group membership points to a simple product and optionally points to a price
When a product combo with customization is added to cart the default customization item for each customization group is added. If there is no default then that group will not have anything added. It is then up to the client to promopt the customer to select additional customization item from each customization group and add them to the order line item tree. We will not actually validate whether a customer have selected the minimum required item from each customization group, for now this will be the responsiblity of the client.
For the big mac combo example we can use the following resources to make it happen:
- kind: "comboWithCustomization", name: "Customized Big Mac Combo", Price: $9.99
- 3 customization groups:
- Name: "Fries Size"; with 3 memberships:
- Product: "Small Fries"; Price: $0.00
- Product: "Medium Fries": Price: $0.00; default
- Product: "Large Fries": Price: $1.00
- Name: "Drink Size"; with 3 memberships:
- Product: "Small Drink"; Price: $0.00
- Product: "Medium Drink"; Price: $0.00; default
- Product: "Large Drink"; Price: $1.00
- Name: "Drink"; with 3 memberships:
- Product: "Coke"; Price: $0.00
- Product: "Sprit"; Price: $0.00
- Product: "Orange Juice"; Price: $0.00
When this product combo with customization is added the initial order line item tree is the following:
- Customized Big Mac Combo x 1 ------------- $9.99
- Big Mac Combo x 1 -------- $9.99
- Medium Fries x 1 --------- $0.00
- Medium Drink x 1 --------- $0.00
The client should then prompt the customer to customize their fries size, drink size and drink, and update the order line item tree accordingly
- Customized Big Mac Combo x 1 ------------- $10.99
- Big Mac Combo x 1 -------- $9.99
- Large Fries x 1 ---------- $1.00
- Medium Drink x 1 --------- $0.00
- Coke x 1 ----------------- $0.00