Full documentation
install:
npm i @plasma-platform/cart -S
- 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
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
-
cartId
string user cart id -
templateId
number product id (isRequired) -
orderId
string order id -
services
Array ids service list -
support
Array ids support list -
locale
String current locale -
data
Object data.license for products | data.channel for services (isRequired) -
itemType
String product type(services or products) (isRequired) -
attributes
Object List of predefined attributes to be stored with cart(affiliate, operator, description, channel) -
currency
String Currency code iso3 -
channel
String current channel -
customAdd
boolean custom create cart with item
UnLink Item(services|product) From Cart
-
link
string 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) -
cartId
string cart id (isRequired) -
type
string type of item (products/services/discounts) (isRequired)
UnLink item(services|product) from item
-
productLink
string product link (product link get from cart item: https://api.templatemonsterdev.com/services/v1/en/services/en/362) (isRequired) -
cartId
string cart id (isRequired) -
typeTarget
string Item or discount type (products/services/promocodes/link-discounts) (isRequired) -
typeSource
string Item or discount type (products/services/promocodes/link-discounts) (isRequired) -
itemId
number item id (isRequired)
deleteItemFromItem({
productLink: 'https://api.templatemonsterdev.com/services/v1/services/en/362',
cartId: 'asd3253464oidfgds',
typeTarget: 'products',
typeSource: 'services',
itemId: 55555,
});
get current user or anonymous cart. takes authorized user cart or anonymous cart from cookies(cart_id)
-
locale
String current locale -
id
String cart id(if don't id automatically taken cart id from cookies)
get products info items from cart
-
cartItems
Array array items from cart (use selector getCartItemsSelector) (isRequired) -
locale
Selector current locale
link item(services|product) in user cart
-
productId
Number product id (isRequired) -
cartId
String user cart id (isRequired) -
itemType
String products type (isRequired) -
data
Object data.license for products | data.channel for services (isRequired) -
orderId
String order id
link item(services) in product
-
serviceId
Number service id (isRequired) -
productId
Number products id (isRequired) -
cartId
String user cart id (isRequired) -
channel
String service channel (isRequired) -
multiLink
Boolean true - if need add several services then field 'linkServices'(isRequired). -
linkServices
String services links. (https://api.templatemonsterdev.com/services/v1/services/362, https://api.templatemonsterdev.com/services/v1/services/966) (isRequired if field 'multiLink' = true) -
itemType
String type of item (services, support) -
locale
String locale -
currency
String current locale currency
create new cart
-
attributes
Object List of predefined attributes to be stored with cart(affiliate, operator, description, channel) -
currency
String Currency code iso3 -
locale
String cart locale
reassign anonymous cart to user (cookies(access_token) isRequired)
-
locale
String current locale -
cartId
String anonymous cart id (isRequired) -
userId
String user profile id (isRequired)
show services popup
-
show
Boolean show or hide popup (isRequired) -
templateId
Number product id (isRequired) -
serviceId
Number service id (isRequired)
subscription centrifuge
-
cartId
String user cart id (isRequired) -
currentLocale
String current locale -
templateId
Number template id. if need add products after subscription centrifuge -
servicesProduct
Array services ids. if need add services in product after subscription centrifuge -
support
Array support ids. if need add support to product after subscription centrifuge -
data
Object data.license for products | data.channel for services -
addItemAfterSubscribe
Boolean if need add products after subscription centrifuge -
itemType
String item type -
channel
String current channel -
anonymousCartId
String anonymous cart id if need merge carts
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.
-
cartId
String cart id (isRequired) -
attributes
Object List of predefined attributes to be stored with cart(affiliate, operator, description, channel) -
currency
String Currency code iso3 -
locale
String Locale in db format
Check on valid promocode, link or unlink promocode
-
promocode
string current promocode. (isRequired) -
cartId
string id of current cart. (isRequired) -
addPromocode
boolean add or remove promocode (isRequired)
Get licenses info by ids
Returns array
Get product in the user cart
Returns array
get onCart service with video
-
products
Array products in cart(full info products from service products) (The products must have fields: templateId, package_id, propertyValues) (isRequired) -
productIds
Array product ids by which you need to find services (isRequired) -
locale
string current locale
get recommended product services
-
product
Object full info product from service products(The product must have fields: templateId, package_id, propertyValues * ) (isRequired) -
locale
String current locale
get onCart services by channel suggestions
-
products
Array products in cart(full info products from service products) (The products must have fields: templateId, package_id, propertyValues) (isRequired) -
productIds
Array product ids by which you need to find services (isRequired) -
locale
string current locale
get services info
get support info
get support info
-
npm i @plasma-platform/cart
-
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
-
in your project's store: 1. import { Cookies } from 'react-cookie'; 2. compose(applyMiddleware(thunkMiddleware.withExtraArgument(cookies)))
-
in your project's reducers: 1. import { cartReducer } from '@plasma-platform/cart'; 2. connect cartReducer (cart: cartReducer)
-
import and use needed Actions or Selectors in your project(Actions example: getCart -> getCartAction, Selectors example: getMyCartId -> getMyCartIdSelector)
cart reducers
set init config for cart actions
-
params
Object services URLs
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,
});
return general information from cart
-
state
Object current store
Returns Object
return current cart id from store
-
state
Object current store
Returns String
return all store carts
-
state
Object current store
Returns Object
return sign that the cart is recalculate
-
state
Object current store
Returns Boolean
return sign that the cart is fetching
-
state
Object current store
Returns Boolean
return service info for popup
-
state
Object current store
Returns Object
return cart info by id
Returns Object
return number of items in the cart
-
state
Object current store
Returns Number
return price in cart
-
state
Object current store
Returns Number
return sign if cart calculated
-
state
Object current store
Returns Boolean
return final price in cart
-
state
Object current store
Returns Number
return last opened cart
-
state
Object current store
Returns Object
return items in cart
-
state
Object current store
Returns Array
return id items in cart
-
state
Object current store
Returns Array
return discounts in cart
-
state
Object current store
Returns Array
return added id services in cart
-
state
Object current store
Returns Array
return sign that firs added item to cart
-
state
Object current store
Returns Boolean
return sign that cart is subscription centrifuge
-
state
Object current store
Returns Boolean
return sign that the cart update is fetching
-
state
Object current store
Returns Boolean
return current applicability discount info
-
state
Object current store
Returns Object
return all licenses in store
-
state
Object current store
Returns Object
return all licenses ids in store
-
state
Object current store
Returns Array
return sign that licenses is fetching
-
state
Object current store
Returns Boolean
return current licenses locale
-
state
Object current store
Returns String
return full info lisenses by ids
Returns Array
return all products in store
-
state
Object current store
Returns Object
return sign that current products locale
-
state
Object current store
Returns String
return sign that products is fetching
-
state
Object current store
Returns Boolean
return current product info from store
-
state
Object current store id
Returns Object
return licenses ids by template id
-
state
Object current store id
Returns Array
return all services in store
-
state
Object current store
Returns Object
return id on Cart Banner Services
-
state
Object current store
Returns Array
return sign that current on Cart Banner Service locale
-
state
Object current store
Returns String
return id on CartSuggestion Services
-
state
Object current store
Returns Array
return sign that current on CartSuggestion Services locale
-
state
Object current store
Returns String
return sign that current services locale
-
state
Object current store
Returns String
return sign that on Cart Suggestion Services is initialized
-
state
Object current store
Returns Boolean
return sign that on Cart Banner Service is initialized
-
state
Object current store
Returns Boolean
return recommended services info by product id
Returns Array
return sing that current locale services by product id
Returns String
return template ids with added service ids
-
state
Object current store
Returns Object
return added services by product id
Returns Array
return sing that services is fetching
-
state
Object current store
Returns Boolean
return sing that on Cart Suggestion Services is fetching
-
state
Object current store
Returns Boolean
return on Cart Banner Service ids
-
state
Object current store
Returns Array
return on Cart Suggestion Services ids
-
state
Object current store
Returns Array
return on Cart Banner Service info
-
state
Object current store
Returns Object
return on Cart Suggestion Services info
-
state
Object current store
Returns Array
return all support in store
-
state
Object current store
Returns Object
return sign that current support locale
-
state
Object current store
Returns String
return sing that support is fetching
-
state
Object current store
Returns Boolean
return support by id from list
-
state
Object current store id
Returns Boolean