Svelte Commerce × OpenCart
Svelte Commerce on OpenCart
OpenCart is the most constrained backend of the 26. Its core API is for order management, not a storefront: ten controllers, and none for products, categories or search. At 9 of 43, the connector is not usable for a store yet.
- 9/43 services wired
- @misiki/opencart-connector 0.5.0
- Cart wired
- Checkout wired
- Sign-in (auth) no endpoint on the platform
What works on OpenCart today
Not usable for a store yet. With catalogue and search unwired, the storefront has no products to show, and none of the ways it places an order is implemented either. OpenCart core ships exactly ten API controllers — cart, coupon, currency, customer, login, order, payment, reward, shipping, voucher — so 9 of 43 is the honest ceiling for that API, not a to-do list.
Cart
Wired: issues a real request to OpenCart.
Checkout
Wired: issues a real request to OpenCart.
Sign-in (auth)
No endpoint on OpenCart: it throws NotSupportedError rather than pretend.
Known gaps: catalogue, search, auth, address, user, profile, coupon, page, wishlist, vendor
9 of 43 services wired, read from CONNECTORS.md on ; npm may carry a newer patch. How coverage is measured.
What the connector calls on OpenCart
The connector calls the core API of OpenCart 3.0.x through the single entry point /index.php, naming each endpoint in the route query parameter (route=api/cart/products), and it does not work with OpenCart 4, whose routes differ.
The connector posts the API user’s username and key to route=api/login and replays the returned api_token, which is a PHP session ID, as a query parameter on every api/* call, logging in again after 50 minutes; there is no Authorization header, and shopper sign-in is not possible because OpenCart has no customer login endpoint.
| Service | What it requests |
|---|---|
cart | GET route=api/cart/products to read the cart, POST route=api/cart/add with product_id, quantity and option, and POST route=api/cart/edit or route=api/cart/remove with the line’s key |
cart | POST route=api/coupon with coupon to apply a code |
checkout | POST route=api/shipping/address and POST route=api/payment/address to put one address of each kind on the session |
checkout | GET route=api/shipping/methods for the rates and POST route=api/shipping/method with shipping_method to choose one |
payment-method | GET route=api/payment/methods, and POST route=api/payment/method with payment_method to choose one |
order | GET route=api/order/info&order_id= only through an admin-only method, never from a shopper-facing call |
OpenCart rules the connector follows
- Request bodies are form-encoded with PHP bracket notation, such as
option[11]=42, because OpenCart’s controllers read only form posts and treat a JSON body as empty. - Failures come back as HTTP 200 with an
errorkey, and an expired session never returns a 401, so the connector throws on anyerrorkey and treatserror.warningon the cart and address routes as the expiry signal. - The cart, coupon, addresses and chosen methods all live in the one session behind the
api_token, so a token supplied for a shopper is never refreshed or swapped for another, which would hand that shopper someone else’s cart. - OpenCart 3 has no route to remove a coupon, so the connector posts a code longer than the 20-character coupon column to
route=api/coupon, which clears the stored coupon before rejecting the code. - No API controller takes
pageorlimitor returns a count, so lists report only the size of the set that came back.
Read from the source of misiki-in/opencart-connector at commit 44a89bb of . Where the code has changed since, the code is right.
Quick start
From nothing to a Svelte Commerce storefront reading OpenCart. You need Node.js and a OpenCart to point it at; the storefront holds no data of its own.
Clone it, choose the connector, point it at OpenCart
# 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/opencart-connector
# 3 — point it at your OpenCart store
echo PUBLIC_OPENCART_API_URL=https://your-store.example.com >> .env
echo PUBLIC_OPENCART_API_KEY=... >> .env
echo PUBLIC_OPENCART_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_OPENCART_API_URL | Yes | Your OpenCart store’s URL. Boot fails, naming this variable, if it is missing. |
PUBLIC_OPENCART_API_KEY | No | The API user’s username, from System › Users › API in the OpenCart admin. See the limitations. |
PUBLIC_OPENCART_API_SECRET | No | That API user’s key. |
PUBLIC_OPENCART_ACCESS_TOKEN | No | An API session token to use instead of logging in. It belongs to one shopper’s cart session, and the connector never swaps it for another. |
PUBLIC_CONNECTOR | No | Only when more than one connector is installed: @misiki/opencart-connector names the one this build runs on. |
init.ts hands the connector every PUBLIC_OPENCART_* variable that is set, camel-cased. The guide also lists PUBLIC_OPENCART_ACCESS_KEY, PUBLIC_OPENCART_STORE_ID and PUBLIC_OPENCART_CHANNEL_ID; 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 OpenCart
- Create an API user under System › Users › API in the OpenCart admin; its username and key go in
PUBLIC_OPENCART_API_KEYandPUBLIC_OPENCART_API_SECRET.
How the integration works
OpenCart core’s API (route=api/...) is for order management, not for a storefront catalogue. The connector wires what it can: the cart, shipping and payment addresses and methods on the API session, and shipping rates. There is no product, category or search controller to call.
api/order/info has no ownership check at all — any API caller can read any order — so the connector quarantines it behind an admin-only method that a shopper-facing call can never reach.
Limitations on OpenCart
- Not usable for a store yet: without the catalogue and search, there is nothing for a shopper to browse.
- No order can be placed. Placing an order (
route=api/order/add) needs a customer, both addresses and shipping and payment methods on the API session, which the storefront’s checkout calls cannot supply; every way the storefront places an order is unsupported. - Catalogue: not wired — OpenCart core has no product or category API controller, so the storefront has no products to list.
- Search: not wired — there is no search controller either.
- The API username and key come from
PUBLIC_OPENCART_API_KEYandPUBLIC_OPENCART_API_SECRET. SvelteKit sendsPUBLIC_variables to the browser, so every visitor can read them and use that API user’s order-management access.
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.
An open question for OpenCart’s maintainers: Is a storefront REST surface planned for OpenCart 4, or is a custom extension the expected route?
Offer a sandbox or a correctionFAQ
Questions about Svelte Commerce on OpenCart
Can I run an OpenCart store on Svelte Commerce today?
No. The connector has no catalogue or search to show — OpenCart core has no API for them — and the storefront cannot place an order through it. At 9 of 43 services, it is not usable for a store yet.
How do I switch Svelte Commerce to OpenCart?
Remove the connectors the storefront ships with, install @misiki/opencart-connector, set PUBLIC_OPENCART_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 is OpenCart only at 9 of 43?
Because that is what OpenCart core’s API offers. It ships exactly ten API controllers — cart, coupon, currency, customer, login, order, payment, reward, shipping and voucher — for order management, with none for products, categories or search. The Svelte Commerce maintainers have asked OpenCart’s maintainers whether a storefront REST API is planned for OpenCart 4.
Sources
OPENCART.md, read on ; CONNECTORS.md, read on ; the connector’s source at 44a89bb. Where they disagree with this page, they are right. OpenCart is a trademark of its owner, named only to describe compatibility; see trademarks.