Scripts for carts
!version
!nextVersion
!downloads
!license
!dependency
*
Full documentation
install: npm i @plasma-platform/cart -S
- ActionsServiceCarts
- addToCartProductsWithServices
- Parameters
- deleteItemFromCart
- Parameters
- deleteItemFromItem
- Parameters
- Examples
- getCart
- Parameters
- getInfoItemsInCart
- Parameters
- linkItemToCart
- Parameters
- linkItemToItem
- Parameters
- postCart
- Parameters
- reassignCart
- Parameters
- showServicePopup
- Parameters
- subscriptionCentrifuge
- Parameters
- updateCart
- Parameters
- ActionsServiceDiscounts
- getDiscountApplicability
- Parameters
- ActionsServiceLicenses
- getLicensesByIds
- Parameters
- ActionsServiceProducts
- getProductsByIds
- Parameters
- ActionsServiceServices
- getCartBannerServices
- Parameters
- getCartServices
- Parameters
- getCartSuggestionServices
- Parameters
- getServiceByIds
- Parameters
- ActionsServiceSupport
- getSupportByIds
- Parameters
- getSupportByProductIds
- Parameters
- Main
- Start
- cartReducer
- setCartConfig
- Parameters
- Examples
- SelectorsServiceCarts
- getCartInfo
- Parameters
- getMyCartId
- Parameters
- getCarts
- Parameters
- getRecalculateCart
- Parameters
- fetchingCart
- Parameters
- cartServicePopupInfo
- Parameters
- getCartByIdInfo
- Parameters
- getCartCount
- Parameters
- getCartPrice
- Parameters
- isCartCalculated
- Parameters
- getCartFinalPrice
- Parameters
- getLastOpenedCart
- Parameters
- getCartItems
- Parameters
- getCartItemsIds
- Parameters
- getCartDiscounts
- Parameters
- cartAddedOnCartServices
- Parameters
- getIsFirstAddedItemToCart
- Parameters
- getSubscriptionCart
- Parameters
- getUpdateCartIsFetching
- Parameters
- SelectorsServiceDiscounts
- getDiscountsInfo
- Parameters
- SelectorsServiceItems
- SelectorsServiceLicenses
- getLicensesEntities
- Parameters
- getLicensesIds
- Parameters
- isFetchingLicenses
- Parameters
- getCurrentLicensesLocale
- Parameters
- getLicensesInfoByIds
- Parameters
- SelectorsServiceProducts
- getProductsEntities
- Parameters
- getFetchingLocaleProducts
- Parameters
- isProductsFetching
- Parameters
- getProductById
- Parameters
- getLicensesIdsByTemplateId
- Parameters
- SelectorsServiceServices
- getAllServicesEntities
- Parameters
- getProductIdsOnCartBannerService
- Parameters
- getFetchingLocaleOnCartBannerService
- Parameters
- getProductIdsOnCartSuggestionServices
- Parameters
- getFetchingLocaleOnCartSuggestionServices
- Parameters
- getFetchingLocaleServices
- Parameters
- getProductIsInitializedOnCartSuggestionServices
- Parameters
- getProductIsInitializedOnCartBannerService
- Parameters
- getCartPreviewServicesByTemplateId
- Parameters
- getFetchingLocaleServicesByProductId
- Parameters
- getAddedCartServices
- Parameters
- getAddedCartServicesByTemplatesId
- Parameters
- isFetchingServices
- Parameters
- isFetchingOnCartSuggestionServices
- Parameters
- getOnCartBannerServiceIds
- Parameters
- getOnCartSuggestionServicesIds
- Parameters
- getOnCartBannerService
- Parameters
- getOnCartSuggestionServices
- Parameters
- SelectorsServiceSupport
- getSupportEntities
- Parameters
- getFetchingLocaleSupport
- Parameters
- isFetchingSupport
- Parameters
- getSupportById
- Parameters
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
- 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
#### Parameters
- link string product link (product link get from cart item:
service -
product -
discounts -
) (isRequired)
- cartId string cart id (isRequired)
- type string type of item (products/services/discounts) (isRequired)
UnLink item(services|product) from item
#### Parameters
- productLink string product link (product link get from cart item:
- 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)
#### Examples
``javascript`
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)
#### Parameters
- locale String current localeid
- String cart id(if don't id automatically taken cart id from cookies)
get products info items from cart
#### Parameters
- cartItems Array array items from cart (use selector getCartItemsSelector) (isRequired)locale
- Selector current locale
link item(services|product) in user cart
#### Parameters
- 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
#### Parameters
- 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. (itemType
- String type of item (services, support)locale
- String localecurrency
- String current locale currency
create new cart
#### Parameters
- attributes Object List of predefined attributes to be stored with cart(affiliate, operator, description, channel)currency
- String Currency code iso3locale
- String cart locale
reassign anonymous cart to user (cookies(access_token) isRequired)
#### Parameters
- locale String current localecartId
- String anonymous cart id (isRequired)userId
- String user profile id (isRequired)
show services popup
#### Parameters
- show Boolean show or hide popup (isRequired)templateId
- Number product id (isRequired)serviceId
- Number service id (isRequired)
subscription centrifuge
#### Parameters
- cartId String user cart id (isRequired)currentLocale
- String current localetemplateId
- Number template id. if need add products after subscription centrifugeservicesProduct
- Array services ids. if need add services in product after subscription centrifugesupport
- Array support ids. if need add support to product after subscription centrifugedata
- Object data.license for products | data.channel for servicesaddItemAfterSubscribe
- Boolean if need add products after subscription centrifugeitemType
- String item typechannel
- String current channelanonymousCartId
- 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.
#### Parameters
- cartId String cart id (isRequired)attributes
- Object List of predefined attributes to be stored with cart(affiliate, operator, description, channel)currency
- String Currency code iso3locale
- String Locale in db format
Check on valid promocode, link or unlink promocode
#### Parameters
- promocode string current promocode. (isRequired)cartId
- string id of current cart. (isRequired)addPromocode
- boolean add or remove promocode (isRequired)
Get licenses info by ids
#### Parameters
- ids array licenses ids (isRequired)locale
- string current locale
Returns array
Get product in the user cart
#### Parameters
- templateIds array id templates (isRequired)locale
- string current locale
Returns array
get onCart service with video
#### Parameters
- 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
#### Parameters
- 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
#### Parameters
- 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
#### Parameters
- ids Array id services (isRequired)locale
- String current locale
get support info
#### Parameters
- ids Array id support (isRequired)locale
- String current locale
get support info
#### Parameters
- productIds Array product ids (isRequired)locale
- String current locale
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
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)
cart reducers
set init config for cart actions
#### Parameters
- params Object services URLs
#### Examples
`javascript`
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
#### Parameters
- state Object current store
Returns Object
return current cart id from store
#### Parameters
- state Object current store
Returns String
return all store carts
#### Parameters
- state Object current store
Returns Object
return sign that the cart is recalculate
#### Parameters
- state Object current store
Returns Boolean
return sign that the cart is fetching
#### Parameters
- state Object current store
Returns Boolean
return service info for popup
#### Parameters
- state Object current store
Returns Object
return cart info by id
#### Parameters
- state Object current storeid
- Number cart id
Returns Object
return number of items in the cart
#### Parameters
- state Object current store
Returns Number
return price in cart
#### Parameters
- state Object current store
Returns Number
return sign if cart calculated
#### Parameters
- state Object current store
Returns Boolean
return final price in cart
#### Parameters
- state Object current store
Returns Number
return last opened cart
#### Parameters
- state Object current store
Returns Object
return items in cart
#### Parameters
- state Object current store
Returns Array
return id items in cart
#### Parameters
- state Object current store
Returns Array
return discounts in cart
#### Parameters
- state Object current store
Returns Array
return added id services in cart
#### Parameters
- state Object current store
Returns Array
return sign that firs added item to cart
#### Parameters
- state Object current store
Returns Boolean
return sign that cart is subscription centrifuge
#### Parameters
- state Object current store
Returns Boolean
return sign that the cart update is fetching
#### Parameters
- state Object current store
Returns Boolean
return current applicability discount info
#### Parameters
- state Object current store
Returns Object
return all licenses in store
#### Parameters
- state Object current store
Returns Object
return all licenses ids in store
#### Parameters
- state Object current store
Returns Array
return sign that licenses is fetching
#### Parameters
- state Object current store
Returns Boolean
return current licenses locale
#### Parameters
- state Object current store
Returns String
return full info lisenses by ids
#### Parameters
- state Object current storeids
- Array licenses ids (optional, default [])
Returns Array
return all products in store
#### Parameters
- state Object current store
Returns Object
return sign that current products locale
#### Parameters
- state Object current store
Returns String
return sign that products is fetching
#### Parameters
- state Object current store
Returns Boolean
return current product info from store
#### Parameters
- state Object current storeid
-
Returns Object
return licenses ids by template id
#### Parameters
- state Object current storeid
-
Returns Array
return all services in store
#### Parameters
- state Object current store
Returns Object
return id on Cart Banner Services
#### Parameters
- state Object current store
Returns Array
return sign that current on Cart Banner Service locale
#### Parameters
- state Object current store
Returns String
return id on CartSuggestion Services
#### Parameters
- state Object current store
Returns Array
return sign that current on CartSuggestion Services locale
#### Parameters
- state Object current store
Returns String
return sign that current services locale
#### Parameters
- state Object current store
Returns String
return sign that on Cart Suggestion Services is initialized
#### Parameters
- state Object current store
Returns Boolean
return sign that on Cart Banner Service is initialized
#### Parameters
- state Object current store
Returns Boolean
return recommended services info by product id
#### Parameters
- state Object current storeid
- Number product id
Returns Array
return sing that current locale services by product id
#### Parameters
- state Object current storeid
- Number product id
Returns String
return template ids with added service ids
#### Parameters
- state Object current store
Returns Object
return added services by product id
#### Parameters
- state Object current storeid
- Number product id
Returns Array
return sing that services is fetching
#### Parameters
- state Object current store
Returns Boolean
return sing that on Cart Suggestion Services is fetching
#### Parameters
- state Object current store
Returns Boolean
return on Cart Banner Service ids
#### Parameters
- state Object current store
Returns Array
return on Cart Suggestion Services ids
#### Parameters
- state Object current store
Returns Array
return on Cart Banner Service info
#### Parameters
- state Object current store
Returns Object
return on Cart Suggestion Services info
#### Parameters
- state Object current store
Returns Array
return all support in store
#### Parameters
- state Object current store
Returns Object
return sign that current support locale
#### Parameters
- state Object current store
Returns String
return sing that support is fetching
#### Parameters
- state Object current store
Returns Boolean
return support by id from list
#### Parameters
- state Object current storeid`
-
Returns Boolean