Svelte Commerce × CS-Cart
Svelte Commerce on CS-Cart
The CS-Cart connector covers browsing, and reads the cart, through CS-Cart’s REST API, which has no checkout resource and no shopper sign-in. It authenticates every call with an admin’s e-mail and API key.
- 20/43 services wired
- @misiki/cs-cart-connector 0.4.0
- Cart wired
- Checkout wired
- Sign-in (auth) no endpoint on the platform
What works on CS-Cart today
Shoppers can browse, but cannot add to a cart: CS-Cart’s cart resource only reads and deletes, so adding, changing or removing a line throws NotSupportedError. They cannot sign in either, and the storefront cannot complete an order. CS-Cart’s REST API has no checkout resource; the one call that creates an order sits in the connector’s orderService.codCheckout(), which the storefront’s payment step does not call, so every way it places an order throws NotSupportedError.
Cart
Wired: issues a real request to CS-Cart.
Checkout
Wired: issues a real request to CS-Cart.
Sign-in (auth)
No endpoint on CS-Cart: it throws NotSupportedError rather than pretend.
Known gaps: auth, address, country, state, currency, coupon, wishlist
20 of 43 services wired, read from CONNECTORS.md on ; npm may carry a newer patch. How coverage is measured.
What the connector calls on CS-Cart
The connector calls CS-Cart’s JSON REST API, API 1.0 under /api for almost everything and the /api/2.0 prefix for reviews through /discussions.
Every call carries Authorization: Basic built from an admin’s e-mail and API key, with no token, cookie or session to capture or refresh; shopper sign-in is not possible, because every authService method that would establish an identity throws NotSupportedError.
| Service | What it requests |
|---|---|
product | GET /api/products with q, pname=Y, status=A, sort_by, sort_order, page and items_per_page; GET /api/products/{id}, GET /api/options?product_id= and GET /api/product_variations?variations_by_product_id= |
category | GET /api/categories with page and items_per_page, GET /api/categories/{id}, and GET /api/categories/{id}/products |
search | GET /api/products with q, pname, pkeywords, cid with subcats=Y, price_from, price_to and status=A |
cart | GET /api/carts/{user_id}, read only |
checkout | GET /api/shippings for the store’s shipping methods |
order | GET /api/orders with email, user_id, status and company_id, GET /api/orders/{id}, and POST /api/stores/{company_id}/orders (or POST /api/orders on Multi-Vendor) with payment_id, shipping_id, products and coupon_codes |
payment-method | GET /api/payments, read in one page and narrowed in the connector to active methods |
CS-Cart rules the connector follows
- Every request sends
Content-Type: application/json, GET included, because CS-Cart otherwise assumestext/plainand the request fails. - Every list call passes
items_per_page, because CS-Cart otherwise uses the merchant’s “Elements per page” setting, and totals are read from the body’sparams.total_items, which CS-Cart sends as a string like every other value. - Flags are sent as
YorNand statuses asA,DorH, so the connector filters storefront lists withstatus=A; product sorting is limited to thesort_byvaluesdate,status,list_price,product,price,codeandamount. - Creating an order returns only
{ "order_id": ... }, so the connector reads the order back withGET /api/orders/{id}; for a registered shopper CS-Cart ignores the posteduser_dataand uses the address on their profile.
Read from the source of misiki-in/cs-cart-connector at commit e99684e of . Where the code has changed since, the code is right.
Quick start
From nothing to a Svelte Commerce storefront reading CS-Cart. You need Node.js and a CS-Cart to point it at; the storefront holds no data of its own.
Clone it, choose the connector, point it at CS-Cart
# 1 — get the storefront
git clone https://github.com/itswadesh/svelte-commerce
cd svelte-commerce
# 2 — one connector at a time: remove the two the storefront ships with, add this one
npm uninstall @misiki/litekart-connector @misiki/vendure-connector
npm i @misiki/cs-cart-connector
# 3 — point it at your CS-Cart store
echo PUBLIC_CS_CART_API_URL=https://your-store.example.com >> .env
echo PUBLIC_CS_CART_API_KEY=admin@example.com >> .env
echo PUBLIC_CS_CART_API_SECRET=... >> .env
# 4 — run it
npm run dev Switching works the same way on every backend: what all 26 share, from one connector at a time to store identity.
Environment variables
| Variable | Required | What it does |
|---|---|---|
PUBLIC_CS_CART_API_URL | Yes | Your CS-Cart store’s URL. Boot fails, naming this variable, if it is missing. |
PUBLIC_CS_CART_API_KEY | No | Despite the name, an admin’s e-mail address — the HTTP Basic username. See the limitations. |
PUBLIC_CS_CART_API_SECRET | No | The API key generated for that admin in the CS-Cart admin panel — the HTTP Basic password. |
PUBLIC_CS_CART_STORE_ID | No | Company ID for company-scoped routes on CS-Cart Ultimate and Multi-Vendor, such as /api/stores/{id}/orders. PUBLIC_CS_CART_CHANNEL_ID is read if it is unset. |
PUBLIC_CS_CART_CHANNEL_ID | No | Read as the company ID when PUBLIC_CS_CART_STORE_ID is unset. |
PUBLIC_CONNECTOR | No | Only when more than one connector is installed: @misiki/cs-cart-connector names the one this build runs on. |
init.ts hands the connector every PUBLIC_CS_CART_* variable that is set, camel-cased. The guide also lists PUBLIC_CS_CART_ACCESS_TOKEN and PUBLIC_CS_CART_ACCESS_KEY; the connector’s source does not read them.
Every variable here begins PUBLIC_, and SvelteKit sends PUBLIC_ variables to the browser: treat each value you set as published.
What to set up on CS-Cart
- Generate an API key for an admin in the CS-Cart admin panel — and read the limitations before putting it anywhere a browser can see.
How the integration works
CS-Cart has one REST surface under two version prefixes, authenticated with HTTP Basic: an admin’s e-mail as the username and their generated API key as the password. On CS-Cart Ultimate and Multi-Vendor many routes are company-scoped, and the connector reads the company ID from the store variable rather than assuming 1.
There is no checkout entity in the REST API: payment methods are configuration records, and the only call that places an order is POST /api/orders, which creates it unpaid. The connector puts that in orderService.codCheckout(), and leaves every capture unimplemented, because marking an order paid without verifying a payment provider’s signature would be a fraud hole.
Limitations on CS-Cart
- The storefront cannot complete an order. Its payment step calls one method per gateway, and on CS-Cart each throws
NotSupportedError; the connector’sorderService.codCheckout(), which does create an order, is not called by the storefront yet. - The connector signs every call with an admin’s e-mail and API key, taken from
PUBLIC_CS_CART_API_KEYandPUBLIC_CS_CART_API_SECRET. SvelteKit sendsPUBLIC_variables to the browser, so every visitor to the store can read both and use that admin’s API access.
Troubleshooting CS-Cart
| When you see | What to do |
|---|---|
| Boot fails with “the cs-cart connector is active but PUBLIC_CS_CART_API_URL is not set” | Add PUBLIC_CS_CART_API_URL to .env. A production Node build and Docker read PUBLIC_* from the process environment rather than .env, so set it on your deploy platform too. |
Before you rely on it
No connector has been exercised against a live production instance of its platform; each was written from the platform’s published source. The limits every backend shares and the errors every switch can meet are on the backends page.
Offer a sandbox or a correctionFAQ
Questions about Svelte Commerce on CS-Cart
Can I run a CS-Cart store on Svelte Commerce today?
No. Shoppers can browse and fill a cart, but there is no shopper sign-in and the storefront cannot complete an order. The connector also authenticates with an admin’s credentials from PUBLIC_ variables, which every visitor’s browser receives.
How do I switch Svelte Commerce to CS-Cart?
Remove the connectors the storefront ships with, install @misiki/cs-cart-connector, set PUBLIC_CS_CART_API_URL in .env and start the dev server. vite.config.ts resolves whichever connector is installed, so no file in the storefront changes.
Why can’t Svelte Commerce complete an order on CS-Cart?
CS-Cart’s REST API has no checkout resource. The only call that places an order, POST /api/orders, lives in the connector’s orderService.codCheckout(), and the storefront’s payment step calls per-gateway methods instead, which throw on CS-Cart.
Sources
CS-CART.md, read on ; CONNECTORS.md, read on ; the connector’s source at e99684e. Where they disagree with this page, they are right. CS-Cart is a trademark of its owner, named only to describe compatibility; see trademarks.