Cart Service - rettersoft/rbs-docs GitHub Wiki
RBS Cart Service
Models
interface ChangeQtyInput{
merchantId: string
variantGroupId: string
itemId: string
cartId?: string // Default value is the default cart of the user
qty?: number // Default value is 1
}
type CartType = "favorite"
type PoolType = "CARGO"|"RESERVED"|"ON_DEMAND"|"SELF"
interface GetCartInput{
cartId?: string // Default value is the default cart of the user
segmentId?: string // Default segmentId is used as default value
zoneId?: string // Default zoneId is used as default value
cartType?: CartType
}
interface CartSummaryInput extends GetCartInput{
serviceFee: number
couponCode?: string
installmentInterestRate?: number
poolType?: PoolType
}
interface Price {
normal: number // Base price
discounted: number // Streaked price
priceAfterPromotions: number // Price after all possible promotions applied
priceAfterInterest: number // Price after all possible interests(like installment interest) applied
}
interface PriceStr {
normal: string // Formatted version of base price
discounted: string // Formatted version of streaked price
priceAfterPromotions: string // Formatted version of price after all possible promotions applied
priceAfterInterest: string // Formatted version of price after all possible interests(like installment interest) applied
}
interface ChildProduct {
variantGroupId: string
id: string
qty: number
}
interface Product {
images: string[]
attributes: any[] // Pim attributes of the product
children?: ChildProduct[] // Child products of bundle product
}
type ItemType = "product"|"serviceFee"|"bag"
interface CartItem {
itemType: ItemType
qty: number
priceWithTax: Price // Singular price of the item with tax
priceWithTaxStr: PriceStr // Formatted version of priceWithTax
totalPriceWithTax: Price // Total price of the item(priceWithTax*qty) with tax
totalPriceWithTaxStr: PriceStr // Formatted version of totalPriceWithTax
priceWithoutTax: Price // Singular price of the item without tax
priceWithoutTaxStr: PriceStr // Formatted version of priceWithoutTax
appliedPromotions: { // Promotions that has been applied to the item
promotionId: string
discount: number
}[]
}
type BundleType = "bundle"|"child"|"none" // Respectively: Bundle product, child of a bundle product, normal product
interface ProductItem extends CartItem {
itemType: "product"
merchantId: string
variantGroupId: string
itemId: string
stock?: number // Stock info only exists if the stock is lower than a certain threshold
product: Product // Product information of the item
bundleType: BundleType
bundleId?: string // Only exists for child products. Indicates the bundle it belongs with the following format: merchantId + "#" + variantGroupId + "#" + itemId
}
type BagType = "regular"|"ice" // Respectively: regular bag, ice bag
interface BagItem extends CartItem {
itemType: "bag"
bagType: BagType // Type of the bag
}
type Item = CartItem|ProductItem|BagItem
interface Suborder{
itemType: ItemType
qty: number
amount: number
quantityCoefficient: number
children?: ChildProduct[]
}
interface Cart{
appliedCampaigns: { // All campaigns that has been applied to the cart
campaignId: string
appliedDiscount: number
}[]
campaignDiscount: number // Campaign discount(streaked price) applied to products
campaignDiscountStr: string // Formatted version of campaignDiscount
items: Item[] // Items of the cart which are grouped and can have qty larger than 1, has all the information for the clients to show
productCount: number // Total number of products in the cart (excluding child products)
totalPriceWithTax: Price // Total price of the cart with tax
totalPriceWithTaxStr: PriceStr // Formatted version of totalPriceWithTax
totalPriceWithoutTax: Price // Total price of the cart without tax
totalPriceWithoutTaxStr: PriceStr // Formatted version of totalPriceWithoutTax
}
interface CartSummary extends Cart{
suborders: SubOrder[] // Items of the cart which are singularized and have qty 1, has only the necessary information for order to process
serviceFeeDiscount: number // Promotion discount applied to service fee
serviceFeeDiscountStr: string // Formatted version of serviceFeeDiscount
promotionDiscount: number // Promotion discount applied to products
promotionDiscountStr: string // Formatted version of promotionDiscount
totalDiscount: number // Total discount applied to the cart (serviceFeeDiscount + promotionDiscount + campaignDiscount)
totalDiscountStr: string // Formatted version of totalDiscount
itemTypeTotals: { // Summed up prices of all item types in the cart
[key: ItemType]: {
totalPriceWithTax: ResponsePrice
totalPriceWithTaxStr: ResponsePriceStr
}
}
promotionSuggestions: { // Suggestions for possible promotions
minAmountForFreeServiceFee?: number // Minimum required cart total price in order to get no service fee
minAmountForFreeServiceFeeStr?: string // Formatted version of minAmountForFreeServiceFee
}
appliedPromotions: { // All promotions that has been applied to the cart
promotionId: string
title: string
appliedDiscount: number
appliedServiceFeeDiscount: number
erpTags: string[]
tags: string[]
}[]
}
All price values are integers and their unit is penny.
Actions
rbs.cart.request.CREATE: Creates new cart
() -> (cartId: string)
rbs.cart.request.ADD_ITEM: Adds item to cart
(addItemInput: ChangeQtyInput) -> ()
rbs.cart.request.REMOVE_ITEM: Removes item from cart
(removeItemInput: ChangeQtyInput) -> ()
rbs.cart.request.GET: Gets cart. Mainly used for listing items.
(promotionId: GetCartInput) -> (Cart)
rbs.cart.request.SUMMARY: Gets cart summary. Mainly used for checkout process.
(promotionId: CartSummaryInput) -> (CartSummary)