Home / Function/ addCartItem() — astro Function Reference

addCartItem() — astro Function Reference

Architecture documentation for the addCartItem() function in cartStore.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  c22706ec_775e_3904_0a66_f2ff24edc7ab["addCartItem()"]
  edd8f249_c500_21a1_e709_e13be23ae578["cartStore.ts"]
  c22706ec_775e_3904_0a66_f2ff24edc7ab -->|defined in| edd8f249_c500_21a1_e709_e13be23ae578
  c08257ed_9b2a_aedc_a11b_c35e957f25e0["AddToCartForm()"]
  c08257ed_9b2a_aedc_a11b_c35e957f25e0 -->|calls| c22706ec_775e_3904_0a66_f2ff24edc7ab
  style c22706ec_775e_3904_0a66_f2ff24edc7ab fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

examples/with-nanostores/src/cartStore.ts lines 16–31

export function addCartItem({ id, name, imageSrc }: CartItemDisplayInfo) {
	const existingEntry = cartItems.get()[id];
	if (existingEntry) {
		cartItems.setKey(id, {
			...existingEntry,
			quantity: existingEntry.quantity + 1,
		});
	} else {
		cartItems.setKey(id, {
			id,
			name,
			imageSrc,
			quantity: 1,
		});
	}
}

Domain

Called By

Frequently Asked Questions

What does addCartItem() do?
addCartItem() is a function in the astro codebase, defined in examples/with-nanostores/src/cartStore.ts.
Where is addCartItem() defined?
addCartItem() is defined in examples/with-nanostores/src/cartStore.ts at line 16.
What calls addCartItem()?
addCartItem() is called by 1 function(s): AddToCartForm.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free