Questions tagged [commerce.js]

Commerce.js is API-first eCommerce infrastructure for developers, with an open source JavaScript SDK

Commerce.js is API-first eCommerce infrastructure for developers, with an open source JavaScript SDK.

Install Commerce.js from npm:

yarn add @chec/commerce.js

Useful resources

32 questions
5
votes
4 answers

Getting an TypeError: t is undefined in React while accessing commerce.js public key

I was trying to access the commercejs Library's Public Key in React. But i failed to do so and met with this error. I can't understand why i am getting this error. src\lib\commerce.js import Commerce from '@chec/commerce.js'; export const commerce…
Avinash Toppo
  • 359
  • 1
  • 4
  • 10
2
votes
0 answers

Commerce.js/Next.js Cart and Billing Form on same page

I need some advice! I am working on a modified version of the Next.js/Commerce.js storefront ChopChop. I have been trying to combine the cart and the checkout page as one by adding the component to the BillingForm.js . . . return <>
Fjott
  • 1,107
  • 3
  • 15
  • 38
2
votes
1 answer

Getting error when reloading the Commerce.js Checkout page (react tutorial)

I'm currently doing the React.js checkout tutorial for the Commerce.js Api. When i click on the checkout button from the cart it takes me to the checkout page and does generate the checkout token as it should, but I've noticed that when i reload the…
Knee-co
  • 333
  • 2
  • 9
2
votes
1 answer

Commerce.js cart.line_items is not returning as an array at the start and is giving me an error

I am trying to find whether my cart is empty by using const isEmpty = !cart.line_items.length;, but it is returning Cannot read property length of undefined. So i console.logged whether cart.line_items is an array and it ends up returning false,…
Arxci
  • 95
  • 1
  • 7
2
votes
4 answers

Cannot 'CAPTURE ORDER' on Commerce JS

I've been trying to build an Ecommerce website using Commerce JS. I'm stuck at 'Capturing Order' phase. Here is my orderData code that I'm sending to Commerce JS to capture, but it returns an error code of 401 & 422. 1st error is this: { …
1
vote
1 answer

Fetching images gallery of 1 product in Commerce.js

Please, tell me how can i fetch all images of 1 individual product in commerce js. Cant find anything in documentation. So, i have a single product, but instead of uploading just 1 photo, I uploaded 20. I can only get the very first photo to be…
Simon Buryat
  • 15
  • 1
  • 7
1
vote
1 answer

Stripe payment gateway ID

The problem in short is that after I finish submitting the test card details on the payment form, It should process the payment with stripe's API via commerceJs. But I keep getting an error saying payment.gateway: Gateway with ID "stripe" not…
BASSAM
  • 11
  • 2
1
vote
0 answers

Prop is not being passed to component but working with other components

I'm in the process of building a merch e-commerce website for a client utilizing the commerce.js API however I've run into a problem. When passing the "cart" object as a prop to the checkout file it returns as an empty object which breaks the…
1
vote
1 answer

Customer Authentication in commercejs

You get the problem reading the title. Is there anyway I can sign up customers using commercejs. The documentation is only showing login/logout methods but not sign up.Is there anyway I can do it through commercjs. Or should I use other…
1
vote
2 answers

Material ui Loading Button Loads all button onClick in React js loop (using map)

So, I was working on commerce.js API. But when I press add to cart, it takes a bit of time to update the cart items number (from API) so I thought I should add a loading button until the cart items load. I found LoadingButton from @mui/lab so I used…
Tauhid
  • 37
  • 7
1
vote
2 answers

Objects are not valid as a React child (found: object with keys {totalItems}). If you meant to render a collection of children, use an array instead

I am trying to update the number on the badge in cart icon in my site and passing the totalItemls={cart.total_items} as a props to navbar but it't throwing me an error that objects are not valid as react chiled. I am using commerce.js api and…
1
vote
2 answers

Module not found: Can't resolve '@chec/commerce.js' on react

I created a file commerce.js in lib doc import Commerce from '@chec/commerce.js'; export const commerce = new Commerce(process.env.REACT_APP_CHEC_PUBLIC_KEY, true); my .env files contains : REACT_APP_CHEC_PUBLIC_KEY=xxxxxxxxxx(key)xxxxxxxxxxxxx I…
Fradé
  • 195
  • 1
  • 2
  • 9
1
vote
0 answers

Unhandled Rejection (TypeError): Cannot read property 'products' of undefined

I am creating an E-Commerce web shop following a tutorial. I would like to display the products that I fetch from an API. There's an error in my code: Unhandled Rejection (TypeError): Cannot read property 'products' of undefined at line: const {…
frank
  • 17
  • 3
1
vote
2 answers

I'm using commerce js on my website, but in the description box, it displays a

tag

I'm creating my first website with reactjs and commerce js, but the description box in commerce js isn't functioning. This is description box of commerce js: This is my code in react: Here is p tag in output:
0
votes
0 answers

Commerce.js add to cart, adding but write undefiend

I have a problem,commerce.js, commerce.cart.add() . I keep adding the products to the cart and it gets added, but in the console it is written that it is undefined. in App.js created a function, with which, when clicked, it takes the product id…
1
2 3