Questions:
...
Expand | |||||
---|---|---|---|---|---|
| |||||
Attention points:
OBS.: It’s possible we need to apply the offer in another context too.
With this update, the frontend is prepared to apply the promo code to loyalty. |
...
Currently, we already sent the sanityId offer to the backend (
intl-partners-service
);Then, we need to send the discount information to Winrest;
With the
sanityId
that we have, we will find the discount values bygetOffers(sanityId: string)
path:
intl-partners-service/src/modules/orders/cart-total.service.ts
We will add a new attribute
orderDiscounts
on the webhookIWebhookPriceOrder
payload;
Note |
---|
We will send it to Winrest always in percentage (requested to Winrest, 'cause will be easier for them); |
The
orderDiscounts
object would be in each cart object;If the discount is
amount
type, we will transform it topercentage
type;E.g: If the total cart is 10 euros and
amount
discount is 5 euros;We will calculate the discount:
Code Block discount = (100 * 5) / 100; discount = 50%;
Acceptance criteria
We can’t impact the other markets;
If there is an offer applied on the “input cart“, we need to send the discount to Winrest;
The discount sento to Winrest should be Percentage
Tasks:
...
title | 1 - TASK: Create a method to calculate the percentage offer; |
---|
...
Create a feature flag;
Create a method to calculate the percentage offer.
...
Acceptance criteria
We can’t impact the other markets;
If there is an offer applied on the “input cart“, we need to send the discount to Winrest;
The discount sent to Winrest should be a percentage;
Tasks:
Expand | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Code Block | | |||||||
|
Code Block | ||
---|---|---|
| ||
{ "callbackUrl": "https://euw3-dev-plk-partners-api.rbictg.com/api/v1/orders/84b5f1df-28df-4e6f-a871-a2783602436f/price/callback", "cart": { "menuSelections": [ { "externalReferenceId": "800853", "id": "f9f5b02e-bee8-4dd1-a5fa-222b79516a98", "menuSelections": [ { "externalReferenceId": "800852", { "externalReferenceIdid": "800853item_67167", "id "menuSelections": "f9f5b02e-bee8-4dd1-a5fa-222b79516a98"[], "menuSelections": [ "price": { { "externalReferenceIdamount": "800852"679, "idcurrency": "item_67167EUR", "menuSelections": []}, "pricequantity": {1 } "amount": 679, ], "currencyprice": "EUR"{ }, "amount": 1100, "quantitycurrency": 1,"EUR" }, "orderDiscounts": [ "quantity": 1 } { ] }, "typechannel": "percentageWHITELABEL_IN_STORE", "value": 50 } ] }, { "externalReferenceId": "940151", "id": "item_50929", "menuSelections": [], "price": { "amount": 0, "currency": "EUR" }, "quantity": 1, "orderDiscounts": [ { "type": "percentage", "value": 50 } ] }, { "externalReferenceId": "940180", "id": "item_66018", "menuSelections": [], "price": { "amount": 1500, "currency": "EUR" }, "quantity": 1, "orderDiscounts": [ { "type": "percentage", "value": 50 } ] }, { "externalReferenceId": "940325", "id": "45adf5bb-2f3d-4c40-a735-cf59d5a661ef", "menuSelections": [], "price": { "amount": 0, "currency": "EUR" }, "quantity": 1, "orderDiscounts": [ { "type": "percentage", "value": 50 } ] } ], "price": { "amount": 1100, "currency": "EUR" }, "quantity": 1, "orderDiscounts": [ { "type": "percentage", "value": 50 } ] } ] }, "channel": "WHITELABEL_IN_STORE", "fees": [], "id": "84b5f1df-28df-4e6f-a871-a2783602436f", "instructions": [], "serviceMode": "TAKEOUT", "storeId": "1111" } |
If the discount offer is a type
percentage
we will return the percentage value;The method example is on branch poc: https://github.com/rbilabs/intl-partners-service/tree/poc/IBFEC-934-send-discount-offers-to-winrest
path:
intl-partners-service/src/modules/orders/orders.service.ts
method name:
mapOffersDiscounts
Expand | ||
---|---|---|
| ||
|
Expand | |||||
---|---|---|---|---|---|
| |||||
|
Expand | ||||||
---|---|---|---|---|---|---|
| ||||||
We will need to send the new discount attribute to Winrest by webhook: Then, we will add the new attribute on mapper So we will add the variable In this method, we will add a new condition to send the discount values:
Where, the Code Block | | |||||
|
"fees": [],
"id": "84b5f1df-28df-4e6f-a871-a2783602436f",
"instructions": [],
"serviceMode": "TAKEOUT",
"storeId": "1111",
"orderDiscounts": [
{
"type": "percentage", // or amount
"value": 50
}
]
} |
Screenshots
N/A
POC
FRONTEND (WHITELABEL)
BACKEND (INTL-PARTNERS-SERVICE)
...