Components & TypeScript
Components
SnipcartSetup
Used to install the Snipcart library.
- Requires the environment variable
PUBLIC_SNIPCART_API_KEY
to be set. - Must be inserted into the
<head>
, such as in a base layout component.
CartCheckout
Used to trigger the opening of the Snipcart dialog.
- Slotted content will automatically trigger opening.
CustomerSignIn
Used to allow a customer to login or signup.
- The account is managed by Snipcart.
- Must be enabled in the Snipcart dashboard. Default is to allow guests only.
- Does nothing if allow guests only is enabled.
CartItemsCount
Used to render the count of total items in the cart.
- Snipcart will render the value.
CartTotalPrice
Used to render the total price of the items in the cart.
- Snipcart will render the value.
Product
Used to define a product that is added to the cart when the user interacts with the component.
- This is a renderless component. That is, it does not visually render anything other than the slotted content and the appropriate Snipcart
data
attributes. - Clicking this component triggers the adding of a product to the cart.
- Snipcart looks for the existence of this component with the appropriate
data
attributes and values as part of it’s order validation (Snipcart can also use a JSON returning API for this).