commerce.js | Open source , JS eCommerce SDK | Ecommerce library
kandi X-RAY | commerce.js Summary
kandi X-RAY | commerce.js Summary
Fast, powerful, and easy to use JavaScript SDK for building and managing carts, checkouts and receipts. Build custom eCommerce experiences to sell physical and digital products from the Chec API. commercejs.com | @commercejs | Slack.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of commerce.js
commerce.js Key Features
commerce.js Examples and Code Snippets
Community Discussions
Trending Discussions on commerce.js
QUESTION
I've had an issue when sending requests to fetch products from the Commerce.js API.
It's that I cannot retrieve the list of attributes I set for each product from the UI that this service provides.
Product Attributes
API Response
In the API docs, it is shown that it's possible to fetch the attributes of each product.
Otherwise, would you please suggest any alternative to Commerce.js that is highly customizable?
...ANSWER
Answered 2022-Mar-28 at 12:32I had the same problem. In case you used Commerce SDK, I tried that at first but it seems that it doesn't return the attributes. Instead you can try retrieving the products using the fetch API with the secret key. That worked for me
QUESTION
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 it. but the problem is even though that button is inside the loop when pressing onClick all the other button also goes to the loading state. IDK am I missing something or is my coding false?. Please check below & help me. Thanks. :)
Here is the main problem.
Here is the app.js where you can see loading state & other API fetching
products component in app.js. you can see I passed down the products & loading props
products loop & props down to product component
finally the cart loading button in the product component with loading props. it works but all other buttons also loads at the same time.
ANSWER
Answered 2022-Jan-31 at 11:46What you can do is create a map in which you store the loading state for each cart. So cartLoading
will have the following shape:
QUESTION
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 material UI.
i have also console logged the total_items and it outputs a number i just want to pass that number in the badge in the navbar
App.js
...ANSWER
Answered 2022-Jan-06 at 02:08The prop passed to a react component needs to be an object like this:
QUESTION
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 checkout page the console shows the following errors: Image of errors.
And this is the code for the Checkout Page:
...ANSWER
Answered 2021-Nov-10 at 23:25When you initialize cart
in the App
state, it is an empty object {}
. That is passed down as a prop to Checkout
.
As soon as Checkout
mounts, it calls generateCheckoutToken
, which tries to read cart.line_items.length
. If this happens before fetchCart
is called in the parent, cart
is an empty object with no line_items
to count. It's a race condition.
One solution would be to listen for cart
to change in the useEffect
, and only call generateCheckoutToken
when cart
has line_items
. This might not support your future design goals, but it should resolve this error.
QUESTION
I have tried to create a custom email receipt template with SendGrid using commercejs webhooks, by following this tutorial. I have uploaded this github repository to
this test Netlify site. The main code is /functions/email.js
I am pretty sure my .env
variables are correct, still no receipt emails are received and probably send. When checking the Netlify function email log says:
ANSWER
Answered 2021-Oct-03 at 23:57Twilio SendGrid developer evangelist here.
You have installed node-fetch to the project, but the tutorial did not include requiring the library into the function to use it. So you need to require node-fetch
.
The tutorial also fails to require the SendGrid library and set the API key. You should set your SendGrid API key in the environment in Netlify, called something like SENDGRID_API_KEY
. Then add the following to the top of your function:
QUESTION
I'm trying to make a ecommerce site using the commerce.js
library. I have already 8 products in the library API. I have a Products.js
component where I'm passing those array of product objects I got from App.js
and again passing single product object to the Product.js
component. To do this, I'm using mapping function to pass each object as props to the Product.js
component. And I'm receiving this error. I tried commenting out the mapping block and only console logged the products
variable from App.js
and the prop products
in Products.js
, there I'm getting all the 8 products so no problem in there. But I don't get it why I'm getting this error in the mapping function.
App.js
...ANSWER
Answered 2021-Sep-25 at 18:32Do you can to attached screen with error?
I think, you try to read data before is are loading, you can prevent this by add something like this (products.data || []).map for example.. or change default state in App.js on useState({data:[]})
QUESTION
When I deploy React project to Netlify, I'm getting this error: enter image description here
(node:1551) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /opt/build/repo/node_modules/postcss-safe-parser/node_modules/postcss/package.json.
Update this package.json to use a subpath pattern like "./*".
(Use node --trace-deprecation ...
to show where the warning was created)
Creating an optimized production build...
Failed to compile.
./src/assets/css/responsive.css ParserError: Syntax Error at line: 1, column 23 at Array.forEach () at Array.forEach () error Command failed with exit code 1.
responive.css
...ANSWER
Answered 2021-Sep-03 at 07:05The reason behind this is because the react-build-scripts use postcss-safe-parser which sees the addition you're trying to do in the clamp as invalid/not safe. You can resolve the error by adding a calc function to the addition you're trying to perform in the clamp functions.
Notice, we now calculate the values of the addition you're trying to perform in the function parameters:
QUESTION
WHAT I'M TRYING TO DO:
I'm trying to query the Google Analytics Core Reporting API v4 using service account credentials for the following dimensions and metrics (FYI I'm aware that you can only include 7 dimensions per call, I'm just listing all that I ultimately want to use because my issue relates to the METRICS and is consistent no matter which combination of dimensions I include in the call):
...ANSWER
Answered 2021-Mar-19 at 08:13Try to remove ga:sessionDurationBucket
from dimensions and set ga:sessionDuration
as metric.
QUESTION
I'm having a successful deployment
...ANSWER
Answered 2021-Mar-03 at 07:48 in App.js
import { BrowserRouter as Router} from "react-router-dom";
then wrap your components inside Router
{/* */}
QUESTION
I'm wondering if anybody can point me in the right direction. I'm following the dynamic routes documentation on Next JS site - https://nextjs.org/docs/routing/dynamic-routes
Currently I'm rendering all products on the products
page. I'm using getServersideProps
to make the API call. Here is the products page:
ANSWER
Answered 2021-Jan-12 at 21:39I think you'll have a problem with SSR, if you want to pass the id and only show the slug in the URL how will SSR know of your ID if no one will be there to pass it?
You can try something like this, but it will work only in SPA mode.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install commerce.js
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page