MCPcopy
hub / github.com/jamstack-cms/jamstack-ecommerce / calculateTotal

Function calculateTotal

context/mainContext.js:13–20  ·  view source on GitHub ↗
(cart)

Source from the content-addressed store, hash-verified

11const SiteContext = React.createContext()
12
13function calculateTotal(cart) {
14 const total = cart.reduce((acc, next) => {
15 const quantity = next.quantity
16 acc = acc + JSON.parse(next.price) * quantity
17 return acc
18 }, 0)
19 return total
20}
21
22class ContextProviderComponent extends React.Component {
23 componentDidMount() {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected