@plasma-platform/cart v3.3.2
Full documentation
install:npm i @plasma-platform/cart -S
Short documentation
Table of Contents
- ActionsServiceCarts
- ActionsServiceDiscounts
- ActionsServiceLicenses
- ActionsServiceProducts
- ActionsServiceServices
- ActionsServiceSupport
- Main
- SelectorsServiceCarts
- getCartInfo
- getMyCartId
- getCarts
- getRecalculateCart
- fetchingCart
- cartServicePopupInfo
- getCartByIdInfo
- getCartCount
- getCartPrice
- isCartCalculated
- getCartFinalPrice
- getLastOpenedCart
- getCartItems
- getCartItemsIds
- getCartDiscounts
- cartAddedOnCartServices
- getIsFirstAddedItemToCart
- getSubscriptionCart
- getUpdateCartIsFetching
- SelectorsServiceDiscounts
- SelectorsServiceItems
- SelectorsServiceLicenses
- SelectorsServiceProducts
- SelectorsServiceServices
- getAllServicesEntities
- getProductIdsOnCartBannerService
- getFetchingLocaleOnCartBannerService
- getProductIdsOnCartSuggestionServices
- getFetchingLocaleOnCartSuggestionServices
- getFetchingLocaleServices
- getProductIsInitializedOnCartSuggestionServices
- getProductIsInitializedOnCartBannerService
- getCartPreviewServicesByTemplateId
- getFetchingLocaleServicesByProductId
- getAddedCartServices
- getAddedCartServicesByTemplatesId
- isFetchingServices
- isFetchingOnCartSuggestionServices
- getOnCartBannerServiceIds
- getOnCartSuggestionServicesIds
- getOnCartBannerService
- getOnCartSuggestionServices
- SelectorsServiceSupport
ActionsServiceCarts
addToCartProductsWithServices
Adds a product to the cart and services to the product. if there is no cartId and no cookies(cart_id) a new cart is automatically created, adds products and services, and subscribe to the centrifuge
Parameters
cartIdstring user cart idtemplateIdnumber product id (isRequired)orderIdstring order idservicesArray ids service listsupportArray ids support listlocaleString current localedataObject data.license for products | data.channel for services (isRequired)itemTypeString product type(services or products) (isRequired)attributesObject List of predefined attributes to be stored with cart(affiliate, operator, description, channel)currencyString Currency code iso3channelString current channelcustomAddboolean custom create cart with item
deleteItemFromCart
UnLink Item(services|product) From Cart
Parameters
linkstring product link (product link get from cart item: service - https://api.templatemonsterdev.com/services/v1/services/en/362, product - https://api.templatemonsterdev.com/products/v2/products/en/67167 discounts - https://api.templatemonsterdev.com/discounts/v2/discounts/w7lw6o4eswgudt9sfkol05lon ) (isRequired)cartIdstring cart id (isRequired)typestring type of item (products/services/discounts) (isRequired)
deleteItemFromItem
UnLink item(services|product) from item
Parameters
productLinkstring product link (product link get from cart item: https://api.templatemonsterdev.com/services/v1/en/services/en/362) (isRequired)cartIdstring cart id (isRequired)typeTargetstring Item or discount type (products/services/promocodes/link-discounts) (isRequired)typeSourcestring Item or discount type (products/services/promocodes/link-discounts) (isRequired)itemIdnumber item id (isRequired)
Examples
deleteItemFromItem({
productLink: 'https://api.templatemonsterdev.com/services/v1/services/en/362',
cartId: 'asd3253464oidfgds',
typeTarget: 'products',
typeSource: 'services',
itemId: 55555,
});getCart
get current user or anonymous cart. takes authorized user cart or anonymous cart from cookies(cart_id)
Parameters
getInfoItemsInCart
get products info items from cart
Parameters
cartItemsArray array items from cart (use selector getCartItemsSelector) (isRequired)localeSelector current locale
linkItemToCart
link item(services|product) in user cart
Parameters
productIdNumber product id (isRequired)cartIdString user cart id (isRequired)itemTypeString products type (isRequired)dataObject data.license for products | data.channel for services (isRequired)orderIdString order id
linkItemToItem
link item(services) in product
Parameters
serviceIdNumber service id (isRequired)productIdNumber products id (isRequired)cartIdString user cart id (isRequired)channelString service channel (isRequired)multiLinkBoolean true - if need add several services then field 'linkServices'(isRequired).linkServicesString services links. (https://api.templatemonsterdev.com/services/v1/services/362, https://api.templatemonsterdev.com/services/v1/services/966) (isRequired if field 'multiLink' = true)itemTypeString type of item (services, support)localeString localecurrencyString current locale currency
postCart
create new cart
Parameters
attributesObject List of predefined attributes to be stored with cart(affiliate, operator, description, channel)currencyString Currency code iso3localeString cart locale
reassignCart
reassign anonymous cart to user (cookies(access_token) isRequired)
Parameters
localeString current localecartIdString anonymous cart id (isRequired)userIdString user profile id (isRequired)
showServicePopup
show services popup
Parameters
showBoolean show or hide popup (isRequired)templateIdNumber product id (isRequired)serviceIdNumber service id (isRequired)
subscriptionCentrifuge
subscription centrifuge
Parameters
cartIdString user cart id (isRequired)currentLocaleString current localetemplateIdNumber template id. if need add products after subscription centrifugeservicesProductArray services ids. if need add services in product after subscription centrifugesupportArray support ids. if need add support to product after subscription centrifugedataObject data.license for products | data.channel for servicesaddItemAfterSubscribeBoolean if need add products after subscription centrifugeitemTypeString item typechannelString current channelanonymousCartIdString anonymous cart id if need merge carts
updateCart
Update cart, authorization is optional, if cart belongs to user then only that user can update the cart, but anonymous cart can be updated by anyone.
Parameters
cartIdString cart id (isRequired)attributesObject List of predefined attributes to be stored with cart(affiliate, operator, description, channel)currencyString Currency code iso3localeString Locale in db format
ActionsServiceDiscounts
getDiscountApplicability
Check on valid promocode, link or unlink promocode
Parameters
promocodestring current promocode. (isRequired)cartIdstring id of current cart. (isRequired)addPromocodeboolean add or remove promocode (isRequired)
ActionsServiceLicenses
getLicensesByIds
Get licenses info by ids
Parameters
Returns array
ActionsServiceProducts
getProductsByIds
Get product in the user cart
Parameters
Returns array
ActionsServiceServices
getCartBannerServices
get onCart service with video
Parameters
productsArray products in cart(full info products from service products) (The products must have fields: templateId, package_id, propertyValues) (isRequired)productIdsArray product ids by which you need to find services (isRequired)localestring current locale
getCartServices
get recommended product services
Parameters
productObject full info product from service products(The product must have fields: templateId, package_id, propertyValues * ) (isRequired)localeString current locale
getCartSuggestionServices
get onCart services by channel suggestions
Parameters
productsArray products in cart(full info products from service products) (The products must have fields: templateId, package_id, propertyValues) (isRequired)productIdsArray product ids by which you need to find services (isRequired)localestring current locale
getServiceByIds
get services info
Parameters
ActionsServiceSupport
getSupportByIds
get support info
Parameters
getSupportByProductIds
get support info
Parameters
Main
Start
1) npm i @plasma-platform/cart
2) in app.jsx: 1. import { CookiesProvider, Cookies } from 'react-cookie'; 2. const cookies = new Cookies(document.cookie); 3. add to main render 4. import { setCartConfig } from '@plasma-platform/cart'; 5. call setCartConfig({...}) with parameters
3) in your project's store: 1. import { Cookies } from 'react-cookie'; 2. compose(applyMiddleware(thunkMiddleware.withExtraArgument(cookies)))
4) in your project's reducers: 1. import { cartReducer } from '@plasma-platform/cart'; 2. connect cartReducer (cart: cartReducer)
5) import and use needed Actions or Selectors in your project(Actions example: getCart -> getCartAction, Selectors example: getMyCartId -> getMyCartIdSelector)
cartReducer
cart reducers
setCartConfig
set init config for cart actions
Parameters
paramsObject services URLs
Examples
setCartConfig({
sessionStorage: true,
cookiesRoot: '.templatemonsterdev.com',
centrifugeCartURL: '//centrifugo.templatemonsterdev.com/',
services: {
carts: '//api.templatemonsterdev.com/carts/v2/',
products: '//api.templatemonsterdev.com/products/v2/',
services: '//api.templatemonsterdev.com/services/v1/',
support: '//api.templatemonsterdev.com/support/v1/',
discounts: '//api.templatemonsterdev.com/discounts/v2/',
users: '//api.templatemonsterdev.com/users/v1/',
licenses: '//api.templatemonsterdev.com/licenses/v1/',
},
serviceChannels: {
cart: 'tm2-cart',
cartBanner: 'plasma-cart-banner',
cartSuggestions: 'plasma-oncart-suggestion',
},
dataSessionStorage: true || false,
});SelectorsServiceCarts
getCartInfo
return general information from cart
Parameters
stateObject current store
Returns Object
getMyCartId
return current cart id from store
Parameters
stateObject current store
Returns String
getCarts
return all store carts
Parameters
stateObject current store
Returns Object
getRecalculateCart
return sign that the cart is recalculate
Parameters
stateObject current store
Returns Boolean
fetchingCart
return sign that the cart is fetching
Parameters
stateObject current store
Returns Boolean
cartServicePopupInfo
return service info for popup
Parameters
stateObject current store
Returns Object
getCartByIdInfo
return cart info by id
Parameters
Returns Object
getCartCount
return number of items in the cart
Parameters
stateObject current store
Returns Number
getCartPrice
return price in cart
Parameters
stateObject current store
Returns Number
isCartCalculated
return sign if cart calculated
Parameters
stateObject current store
Returns Boolean
getCartFinalPrice
return final price in cart
Parameters
stateObject current store
Returns Number
getLastOpenedCart
return last opened cart
Parameters
stateObject current store
Returns Object
getCartItems
return items in cart
Parameters
stateObject current store
Returns Array
getCartItemsIds
return id items in cart
Parameters
stateObject current store
Returns Array
getCartDiscounts
return discounts in cart
Parameters
stateObject current store
Returns Array
cartAddedOnCartServices
return added id services in cart
Parameters
stateObject current store
Returns Array
getIsFirstAddedItemToCart
return sign that firs added item to cart
Parameters
stateObject current store
Returns Boolean
getSubscriptionCart
return sign that cart is subscription centrifuge
Parameters
stateObject current store
Returns Boolean
getUpdateCartIsFetching
return sign that the cart update is fetching
Parameters
stateObject current store
Returns Boolean
SelectorsServiceDiscounts
getDiscountsInfo
return current applicability discount info
Parameters
stateObject current store
Returns Object
SelectorsServiceItems
SelectorsServiceLicenses
getLicensesEntities
return all licenses in store
Parameters
stateObject current store
Returns Object
getLicensesIds
return all licenses ids in store
Parameters
stateObject current store
Returns Array
isFetchingLicenses
return sign that licenses is fetching
Parameters
stateObject current store
Returns Boolean
getCurrentLicensesLocale
return current licenses locale
Parameters
stateObject current store
Returns String
getLicensesInfoByIds
return full info lisenses by ids
Parameters
Returns Array
SelectorsServiceProducts
getProductsEntities
return all products in store
Parameters
stateObject current store
Returns Object
getFetchingLocaleProducts
return sign that current products locale
Parameters
stateObject current store
Returns String
isProductsFetching
return sign that products is fetching
Parameters
stateObject current store
Returns Boolean
getProductById
return current product info from store
Parameters
stateObject current storeid
Returns Object
getLicensesIdsByTemplateId
return licenses ids by template id
Parameters
stateObject current storeid
Returns Array
SelectorsServiceServices
getAllServicesEntities
return all services in store
Parameters
stateObject current store
Returns Object
getProductIdsOnCartBannerService
return id on Cart Banner Services
Parameters
stateObject current store
Returns Array
getFetchingLocaleOnCartBannerService
return sign that current on Cart Banner Service locale
Parameters
stateObject current store
Returns String
getProductIdsOnCartSuggestionServices
return id on CartSuggestion Services
Parameters
stateObject current store
Returns Array
getFetchingLocaleOnCartSuggestionServices
return sign that current on CartSuggestion Services locale
Parameters
stateObject current store
Returns String
getFetchingLocaleServices
return sign that current services locale
Parameters
stateObject current store
Returns String
getProductIsInitializedOnCartSuggestionServices
return sign that on Cart Suggestion Services is initialized
Parameters
stateObject current store
Returns Boolean
getProductIsInitializedOnCartBannerService
return sign that on Cart Banner Service is initialized
Parameters
stateObject current store
Returns Boolean
getCartPreviewServicesByTemplateId
return recommended services info by product id
Parameters
Returns Array
getFetchingLocaleServicesByProductId
return sing that current locale services by product id
Parameters
Returns String
getAddedCartServices
return template ids with added service ids
Parameters
stateObject current store
Returns Object
getAddedCartServicesByTemplatesId
return added services by product id
Parameters
Returns Array
isFetchingServices
return sing that services is fetching
Parameters
stateObject current store
Returns Boolean
isFetchingOnCartSuggestionServices
return sing that on Cart Suggestion Services is fetching
Parameters
stateObject current store
Returns Boolean
getOnCartBannerServiceIds
return on Cart Banner Service ids
Parameters
stateObject current store
Returns Array
getOnCartSuggestionServicesIds
return on Cart Suggestion Services ids
Parameters
stateObject current store
Returns Array
getOnCartBannerService
return on Cart Banner Service info
Parameters
stateObject current store
Returns Object
getOnCartSuggestionServices
return on Cart Suggestion Services info
Parameters
stateObject current store
Returns Array
SelectorsServiceSupport
getSupportEntities
return all support in store
Parameters
stateObject current store
Returns Object
getFetchingLocaleSupport
return sign that current support locale
Parameters
stateObject current store
Returns String
isFetchingSupport
return sing that support is fetching
Parameters
stateObject current store
Returns Boolean
getSupportById
return support by id from list
Parameters
stateObject current storeid
Returns Boolean
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago