add_to_cart_lines
The lines about to be added to the cart: the add to cart forms (the main line and its add-ons at once), boxes, direct add, buy again, `addToCart`, `addBoxToCart` and `/cart/add.js`. The message of an error a filter throws shows in the form and goes out with `smootify:errors`.
On this page
The lines about to be added to the cart: the add to cart forms (the main line and its add-ons at once), boxes, direct add, buy again, addToCart, addBoxToCart and /cart/add.js. The message of an error a filter throws shows in the form and goes out with smootify:errors.
Add it with Smootify.addFilter: answer the value changed, nothing to keep it, or false to stop.
add_to_cart_lines: ( lines: CartLineInput[], context: AddToCartContext, ) => FilterAnswer<CartLineInput[]> | Promise<FilterAnswer<CartLineInput[]>>Types
CartLineInput
/** A line to add: `merchandiseId` is the variant gid. */
export interface CartLineInput {
merchandiseId: string;
quantity?: number | null;
attributes?: AttributeInput[] | null;
sellingPlanId?: string | null;
parent?: { lineId?: string | null; merchandiseId?: string | null } | null;
}AddToCartContext
/** Where an addition comes from: `element` is the add to cart form, or the button that added (direct add, buy again). */
export interface AddToCartContext {
goToCheckout: boolean;
element?: HTMLElement | undefined;
}FilterAnswer
/** What a filter answers: the value changed, nothing (`undefined`) to keep it, `false` to stop. */
export type FilterAnswer<T> = T | false | undefined;