use Apply Cart Lines Changehook
Returns a function to mutate the lines
property of checkout.
Anchor to useApplyCartLinesChangeuse Apply Cart Lines Change()
CartLineChange
CartLineAddChange | CartLineRemoveChange | CartLineUpdateChange
CartLineAddChange
- type
An identifier for changes that add line items.
"addCartLine"
- merchandiseId
The merchandise ID being added.
string
- quantity
The quantity of the merchandise being added.
number
- attributes
The attributes associated with the line item.
Attribute[]
- sellingPlanId
The identifier of the selling plan that the merchandise is being purchased with.
string
export interface CartLineAddChange {
/**
* An identifier for changes that add line items.
*/
type: 'addCartLine';
/**
* The merchandise ID being added.
* @example 'gid://shopify/ProductVariant/123'
*/
merchandiseId: string;
/**
* The quantity of the merchandise being added.
*/
quantity: number;
/**
* The attributes associated with the line item.
*/
attributes?: Attribute[];
/**
* The identifier of the selling plan that the merchandise is being purchased
* with.
*/
sellingPlanId?: SellingPlan['id'];
}
Attribute
- key
The key for the attribute.
string
- value
The value for the attribute.
string
export interface Attribute {
/**
* The key for the attribute.
*/
key: string;
/**
* The value for the attribute.
*/
value: string;
}
CartLineRemoveChange
- type
An identifier for changes that remove line items.
"removeCartLine"
- id
Line Item ID.
string
- quantity
The quantity being removed for this line item.
number
export interface CartLineRemoveChange {
/**
* An identifier for changes that remove line items.
*/
type: 'removeCartLine';
/**
* Line Item ID.
* @example 'gid://shopify/CartLine/123'
*/
id: string;
/**
* The quantity being removed for this line item.
*/
quantity: number;
}
CartLineUpdateChange
- type
An identifier for changes that update line items.
"updateCartLine"
- id
Line Item ID.
string
- merchandiseId
The new merchandise ID for the line item.
string
- quantity
The new quantity for the line item.
number
- attributes
The new attributes for the line item.
Attribute[]
- sellingPlanId
The identifier of the selling plan that the merchandise is being purchased with or `null` to remove the the product from the selling plan.
string
export interface CartLineUpdateChange {
/**
* An identifier for changes that update line items.
*/
type: 'updateCartLine';
/**
* Line Item ID.
* @example 'gid://shopify/CartLine/123'
*/
id: string;
/**
* The new merchandise ID for the line item.
* @example 'gid://shopify/ProductVariant/123'
*/
merchandiseId?: string;
/**
* The new quantity for the line item.
*/
quantity?: number;
/**
* The new attributes for the line item.
*/
attributes?: Attribute[];
/**
* The identifier of the selling plan that the merchandise is being purchased
* with or `null` to remove the the product from the selling plan.
*/
sellingPlanId?: SellingPlan['id'] | null;
}
CartLineChangeResult
CartLineChangeResultSuccess | CartLineChangeResultError
CartLineChangeResultSuccess
- type
Indicates that the line item was changed successfully.
"success"
export interface CartLineChangeResultSuccess {
/**
* Indicates that the line item was changed successfully.
*/
type: 'success';
}
CartLineChangeResultError
- type
Indicates that the line item was not changed successfully. Refer to the `message` property for details about the error.
"error"
- message
A message that explains the error. This message is useful for debugging. It is **not** localized, and therefore should not be presented directly to the buyer.
string
export interface CartLineChangeResultError {
/**
* Indicates that the line item was not changed successfully. Refer to the `message` property for details about the error.
*/
type: 'error';
/**
* A message that explains the error. This message is useful for debugging.
* It is **not** localized, and therefore should not be presented directly
* to the buyer.
*/
message: string;
}