Skip to content

Powered by Grav CMS + Helios Theme

Customer groups

The groups a pricing rule, a coupon condition, a shipping rule or a member-only product points at.

The groups a pricing rule, a coupon condition, a shipping rule or a member-only product points at. See Customer groups.

List customer groups

GET /api/v1/kahunacart/customer-groups Permission kahunacart.settings

List the store's customer groups with their codes, labels, flat discount percentages and how many customers are in each. A group's code is what a price list rule, a coupon condition or a shipping rule names, so this is the call to make before writing any rule scoped to a kind of customer.

Create a customer group

POST /api/v1/kahunacart/customer-groups Permission kahunacart.settings

Create a customer group. The code is the stable name rules point at and is normalised to lowercase with non-word characters folded to hyphens, so "Trade Customers" becomes trade-customers; omit it and one is made from the label. At most one group is the default, and setting this one as the default takes the flag off whichever group had it.

Parameters

Name Type Description
code optional string The stable name rules point at, e.g. trade. Omit to derive it from the label.
label required string What the merchant calls this group.
description optional string A note about who belongs in it.
position optional integer Sort order in the admin list; lower comes first.
is_default optional boolean Treat customers with no group of their own as being in this one.
discount_percent optional string A flat percentage off everything for this group, as a decimal string ("10" or "8.375"). Leave it out for a group that is an identity rather than a discount. A customer in several groups is given the highest percentage among them. The cart takes it off as a sale of that much on everything, for members who are signed in (and for guests when the group is the default).
show_on_account optional boolean Show this group as a badge on the customer's own account page. Defaults to true; turn it off for internal groups.

Update a customer group

PATCH /api/v1/kahunacart/customer-groups/{id} Permission kahunacart.settings

Change a customer group. Only the fields you send are written. Renaming the code changes what rules must name, so change it only when no rule points at the old one.

Parameters

Name Type Description
id required integer The group to change.
code optional string
label optional string
description optional string
position optional integer
is_default optional boolean
discount_percent optional string
show_on_account optional boolean

Delete a customer group

DELETE /api/v1/kahunacart/customer-groups/{id} Permission kahunacart.settings

Delete a customer group. Its members leave it and keep any other groups they are in — nothing about them or their orders changes — and the answer says how many customers were in it. Rules naming the deleted code stop matching anybody, so check list_customer_groups usage before removing one.

Parameters

Name Type Description
id required integer The group to delete.

Put a customer in a group

POST /api/v1/kahunacart/customers/{id}/group Permission kahunacart.customers.manage

Set the groups one customer is in. A customer may be in several: send group_ids with the whole list (it replaces what they had; an empty list takes them out of every group), or the older group_id for exactly one group, or null for none. Takes effect immediately for every price list, coupon and rule scoped to those groups.

Parameters

Name Type Description
id required integer The customer.
group_ids optional array of integer Every group they should be in, replacing their current groups.
group_id optional integer or null Exactly one group to put them in, or null to take them out of every group. Ignored when group_ids is sent.

A rule names the group's code, never its id and never its label. Codes are normalised on write: lower-cased, non-word characters folded to hyphens, capped at 64 characters.

A product restricted to one or more groups names them by id, in customer_group_ids on the products API. Deleting a group takes its product restrictions with it in the same transaction. See Member-only products.