hydrogen/packages/hydrogen/src/components/CartLinePrice/README.md
2021-11-09 18:20:09 -08:00

1.7 KiB

The CartLinePrice component renders a Money component for the cart line merchandise's price or compare at price. It must be a descendent of a CartLineProvider component.

Example code

import {CartLineProvider, useCart, CartLinePrice} from '@shopify/hydrogen';

export function App() {
  const {lines} = useCart();

  return lines.map((line) => {
    return (
      <CartLineProvider key={line.id} line={line}>
        <CartLinePrice priceType="compareAt" />
      </CartLineProvider>
    );
  });
}

Props

Name Type Description
priceType? "regular" | "compareAt" The type of price. Valid values:regular (default) or compareAt.

Alias

The CartLinePrice component is aliased by the CartLine.Price component. You can use whichever component you prefer.

Component type

The CartLinePrice component is a client component, which means that it renders on the client. For more information about component types, refer to React Server Components.