cscart-sdk
[![Travis (.org)](https://img.shields.io/travis/LFFATE/cscart-sdk-js.svg?style=flat-square)](https://travis-ci.org/LFFATE/cscart-sdk-js) [![npm](https://img.shields.io/npm/dm/cscart-sdk.svg?style=flat-square)](https://www.npmjs.com/package/cscart-sdk) ![C
Last updated 21 days ago by saunterer .
MIT · Original npm · Tarball · package.json
$ cnpm install cscart-sdk 
SYNC missed versions from official npm registry.

Travis (.org) npm Codecov

Description

Installation

in HTML

Copy cscart-sdk.js to your project and add at html:

<script src="cscart-sdk.js"></script>
<script>
  const api = new CsCartApiSdk({
    username: 'USER@EMAIL',
    apiKey: 'APIKEY',
    apiUrl: 'API_URL',
    siteUrl: 'SITE_URL',
  })
</script>

TypeScript

npm i cscart-sdk

import CsCartApiSdk from 'cscart-sdk'
//
const api = new CsCartApiSdk({
  username: 'USER@EMAIL',
  apiKey: 'APIKEY',
  apiUrl: 'API_URL',
  siteUrl: 'SITE_URL',
})

Using

Table of entities and possibilities

Entity Method Description Example
products Products api.products
get() get products list api.products.get()
one(number) get single product by id api.products.one(1).get()
limit(number) Limit products count on request result api.products.limit(50).get()
orderBy(string) Sort products by api.products.orderBy('product')
asc() Sort by increasing api.products.orderBy('price').asc()
desc() Sort by decreasing api.products.orderBy('price').desc()
forCategory(number) Get products only for the category api.products.forCategory(114)
withFilters() Adds to response filters array api.products.withFilters()
forOptions([{ optionId: number, value: any }]) Get product with selected options api.products.forOptions([{ optionId: 17, value: 7 }])
layouts Layouts and blocks api.layouts
get() get layouts list api.layouts.get()
one(number) get single layout api.layouts.one(1).get()
forLocation(string) get layout for dispatch api.layouts.one(3).forLocation('index.index')
withBlocks() get blocks for a found layout api.layouts.one(3).forLocation('index.index').withBlocks()
categories Categories api.categories
get() get categories api.categories.get()
one(number) get single category api.categories.one(50)
auth Auth tokens api.auth
login(email: string, password: string) Try to login with email and password api.auth.login('user@email.com', 'password').then((response: any) => console.log(response.token))
socialLogin(provider: 'google', tokenId: string, clientId: string) Verify auth for social api.auth.socialLogin('google', 'avfgjgjnf...', '10948fhrDs1').then((response: any) => console.log(response.token))
cart Cart api.cart
get() Get cart content api.cart.get()
withShippings(ids?: Array<number>) response will contains shippings info. Ids - chosen_shipping api.cart.withShippings([4, 5]).get()
add(Array<any>) add products to cart api.cart.add([{product_id: 5, amount: 1}])
saveUserData(<any>) Save user info at cart api.cart.saveUserData({ firstname: 'John', s_city: 'Moscow'})
wishlist Wishlist api.wishlist
get() Get wishlist content api.wishlist.get()
add(Array<any>) add products to wishlist api.wishlist.add([{product_id: 5}, {product_id: 18}])
add(<any>) add products to wishlist api.wishlist.add({product_id: 5})
profile Profile api.profile
get() Get profile for current user api.profile.get()
form() Get form fields for... api.profile.form()...
forAddProfile() Get form fields for registration api.profile.form().forAddProfile().get()
forUpdateProfile() Get form fields for update profile api.profile.form().forUpdateProfile().get()
forAddOrder() Get form fields for checkout api.profile.form().forAddOrder().get()
forUpdateOrder() - api.profile.form().forUpdateOrder().get()
create() Create profile api.profile.create({ email: email@email.com", password1: "12345", password2: "12345" })
settlements Settlement api.settlements
create({ orderId: number, repay?: boolean, ...data}) create request to create settlement api.settlements.create({ orderId: 101 })
pages Pages api.pages
get() get pages list api.pages.get()
one(number) get single page by id api.pages.one(1).get()
limit(number) Limit pages count on request result api.pages.limit(50).get()
orderBy(string) Sort pages by api.pages.orderBy('product')
asc() Sort by increasing api.pages.orderBy('price').asc()
desc() Sort by decreasing api.pages.orderBy('price').desc()
forParentPage(number) Get pages only for the parent page api.pages.forParentPage(114)
Settings Storefron information api.settings
get() Get settings for the store api.settings.get()
testimonials Testimonials api.testimonials
forProduct(number) Get testimonials for a product api.testimonials.forProduct(101).get()
forCategory(number) Get testimonials for a category api.testimonials.forCategory(101).get()
forArticle(number) Get testimonials for an article api.testimonials.forArticle(101).get()
forOrder(number) Get testimonials for an order api.testimonials.forOrder(101).get()
forStorefront(number) Get testimonials for a storefront api.testimonials.forStorefront(101).get()
forVendor(number) Get testimonials for a vendor api.testimonials.forVendor(101).get()
vendors Vendors api.vendors
get() get vendors list api.vendors.get()
one(number) get single vendor by id api.vendors.one(1).get()
limit(number) Limit vendors count on request result api.vendors.limit(50).get()
orderBy(string) Sort vendors by api.vendors.orderBy('name')
asc() Sort by increasing api.vendors.orderBy('name').asc()
desc() Sort by decreasing api.vendors.orderBy('name').desc()

Examples

// Get all products
api.products.get().then((response) => {
  console.log(response)
})

// Get all products with pagination
api.products.limit(10).page(5).get().then((response) => {
  console.log(response)
})

// get single product where product_id = 150
api.products.one(150).get().then((response) => {
  console.log(response)
})

// get blocks from block manager for the layout
api.layouts.one(3).forLocation('index.index').withBlocks().get().then((r) => console.log(r)).catch((error) => console.log(error.response))

Current Tags

  • 1.92.5                                ...           latest (21 days ago)

102 Versions

  • 1.92.5                                ...           21 days ago
  • 1.92.4                                ...           a month ago
  • 1.92.3                                ...           a month ago
  • 1.92.2                                ...           a month ago
  • 1.92.1                                ...           a month ago
  • 1.91.56                                ...           2 months ago
  • 1.91.55                                ...           2 months ago
  • 1.91.51                                ...           3 months ago
  • 1.91.50                                ...           3 months ago
  • 1.91.10                                ...           3 months ago
  • 1.9.99                                ...           3 months ago
  • 1.9.97                                ...           3 months ago
  • 1.9.96                                ...           3 months ago
  • 1.9.91                                ...           3 months ago
  • 1.9.81                                ...           4 months ago
  • 1.9.79                                ...           4 months ago
  • 1.9.75                                ...           4 months ago
  • 1.9.71                                ...           4 months ago
  • 1.9.61                                ...           4 months ago
  • 1.9.6                                ...           4 months ago
  • 1.9.51                                ...           5 months ago
  • 1.9.45                                ...           5 months ago
  • 1.9.35                                ...           5 months ago
  • 1.9.30                                ...           5 months ago
  • 1.9.21                                ...           5 months ago
  • 1.9.20                                ...           5 months ago
  • 1.9.10                                ...           5 months ago
  • 1.8.79                                ...           6 months ago
  • 1.8.75                                ...           6 months ago
  • 1.8.71                                ...           6 months ago
  • 1.8.7                                ...           6 months ago
  • 1.8.61                                ...           6 months ago
  • 1.8.6                                ...           6 months ago
  • 1.8.5                                ...           6 months ago
  • 1.8.1                                ...           6 months ago
  • 1.8.0                                ...           6 months ago
  • 1.7.96                                ...           7 months ago
  • 1.7.94                                ...           7 months ago
  • 1.7.84                                ...           7 months ago
  • 1.7.83                                ...           7 months ago
  • 1.7.82                                ...           7 months ago
  • 1.7.81                                ...           7 months ago
  • 1.7.8                                ...           7 months ago
  • 1.7.7                                ...           7 months ago
  • 1.7.5                                ...           7 months ago
  • 1.7.4                                ...           7 months ago
  • 1.7.3                                ...           7 months ago
  • 1.7.2                                ...           7 months ago
  • 1.7.1                                ...           7 months ago
  • 1.6.9                                ...           7 months ago
  • 1.6.85                                ...           8 months ago
  • 1.6.81                                ...           8 months ago
  • 1.6.8                                ...           8 months ago
  • 1.6.73                                ...           8 months ago
  • 1.6.72                                ...           8 months ago
  • 1.6.71                                ...           8 months ago
  • 1.6.7                                ...           8 months ago
  • 1.6.5                                ...           8 months ago
  • 1.6.2                                ...           8 months ago
  • 1.6.1                                ...           8 months ago
  • 1.5.98                                ...           8 months ago
  • 1.5.97                                ...           8 months ago
  • 1.5.96                                ...           8 months ago
  • 1.5.95                                ...           8 months ago
  • 1.5.91                                ...           9 months ago
  • 1.5.9                                ...           9 months ago
  • 1.5.8                                ...           9 months ago
  • 1.5.6                                ...           9 months ago
  • 1.5.5                                ...           9 months ago
  • 1.5.3                                ...           9 months ago
  • 1.5.2                                ...           9 months ago
  • 1.5.1                                ...           9 months ago
  • 1.5.0                                ...           9 months ago
  • 1.4.3                                ...           9 months ago
  • 1.4.1                                ...           9 months ago
  • 1.4.2                                ...           9 months ago
  • 1.4.0                                ...           9 months ago
  • 1.3.0                                ...           9 months ago
  • 1.2.6                                ...           9 months ago
  • 1.2.5                                ...           9 months ago
  • 1.2.4                                ...           9 months ago
  • 1.2.3                                ...           9 months ago
  • 1.2.2                                ...           9 months ago
  • 1.2.1                                ...           9 months ago
  • 1.2.0                                ...           9 months ago
  • 1.1.18                                ...           9 months ago
  • 1.1.17                                ...           9 months ago
  • 1.1.16                                ...           9 months ago
  • 1.1.15                                ...           9 months ago
  • 1.1.14                                ...           9 months ago
  • 1.1.13                                ...           9 months ago
  • 1.1.12                                ...           9 months ago
  • 1.1.11                                ...           9 months ago
  • 1.1.10                                ...           9 months ago
  • 1.1.9                                ...           9 months ago
  • 1.1.7                                ...           9 months ago
  • 1.1.6                                ...           9 months ago
  • 1.1.2                                ...           9 months ago
  • 1.1.1                                ...           9 months ago
  • 1.1.0                                ...           9 months ago
  • 1.0.1                                ...           9 months ago
  • 1.0.0                                ...           9 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 18
Last Day 0
Last Week 0
Last Month 206
Dependencies (8)
Dev Dependencies (16)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |