Skip to content

Commit cd7b1c6

Browse files
authored
Merge pull request #13 from happycog/craft-commerce
Add Commerce, user, and address management CLI tools
2 parents 3529eb9 + 2ddb357 commit cd7b1c6

173 files changed

Lines changed: 12079 additions & 85 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- name: Install dependencies
6464
if: steps.composer-cache.outputs.cache-hit != 'true'
6565
run: |
66-
composer require "craftcms/cms:~5.8.8" --prefer-dist --no-progress
66+
composer require "craftcms/cms:~5.9" --prefer-dist --no-progress
6767
6868
- name: Copy config files
6969
run: |

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ By adding this skill to Claude, you transform your Craft CMS site into an AI-acc
2424
- **Field Layout Management**: Build and modify field layouts programmatically
2525
- **Draft Support**: Create, update, and apply drafts for content workflows
2626
- **Asset Management**: Upload, update, and manage assets and volumes
27+
- **Address Management**: Create, read, update, and delete owner-backed addresses plus manage the global address field layout
28+
- **User Management**: Create, read, update, and delete users plus inspect the global user field layout
29+
- **User Group Management**: Manage user groups and permissions on Craft Pro installations
2730
- **Site Information**: Access multi-site configuration details
31+
- **Commerce: Products**: Create, read, update, and delete products with variant support
32+
- **Commerce: Variants**: Manage product variants with pricing, inventory, and dimensions
33+
- **Commerce: Orders**: Search and manage orders with status updates
34+
- **Commerce: Stores**: View and configure store settings, checkout behavior, and pricing strategies
2835

2936
## Installation
3037

@@ -253,12 +260,65 @@ All tools from the HTTP API are available via CLI. Common operations include:
253260
- `assets/delete <id>` - Delete asset
254261
- `volumes/list` - List asset volumes
255262

263+
### Addresses
264+
- `addresses/list` - List/search addresses
265+
- `addresses/get <id>` - Get address by ID
266+
- `addresses/create` - Create address for an owner or address field
267+
- `addresses/update <id>` - Update address
268+
- `addresses/delete <id>` - Delete address
269+
- `addresses/field-layout` - Get the global address field layout
270+
271+
### Users
272+
- `users/list` - List/search users
273+
- `users/get <id>` - Get user by ID
274+
- `users/create` - Create user
275+
- `users/permissions` - List available user permissions
276+
- `users/update <id>` - Update user
277+
- `users/delete <id>` - Delete user
278+
- `users/field-layout` - Get the global user field layout
279+
280+
### User Groups
281+
- `user-groups/list` - List user groups
282+
- `user-groups/get <id>` - Get user group by ID
283+
- `user-groups/create` - Create user group
284+
- `user-groups/update <id>` - Update user group
285+
- `user-groups/delete <id>` - Delete user group
286+
256287
### Other
257288
- `sites/list` - List all sites
258289
- `field-layouts/create` - Create field layout
259290
- `field-layouts/get` - Get field layout
260291
- `field-layouts/update <id>` - Update field layout
261292

293+
### Commerce: Products
294+
- `products/create` - Create new product
295+
- `products/get <id>` - Get product by ID
296+
- `products/search` - Search/filter products
297+
- `products/update <id>` - Update product
298+
- `products/delete <id>` - Delete product
299+
- `product-types/list` - List product types
300+
- `product-types/get <id>` - Get product type by ID with field layouts
301+
- `product-types/create` - Create product type
302+
- `product-types/update <id>` - Update product type
303+
- `product-types/delete <id>` - Delete product type
304+
305+
### Commerce: Variants
306+
- `variants/create` - Create variant for a product
307+
- `variants/get <id>` - Get variant by ID
308+
- `variants/update <id>` - Update variant
309+
- `variants/delete <id>` - Delete variant
310+
311+
### Commerce: Orders
312+
- `orders/get <id>` - Get order by ID
313+
- `orders/search` - Search/filter orders
314+
- `orders/update <id>` - Update order status
315+
- `order-statuses/list` - List order statuses
316+
317+
### Commerce: Stores
318+
- `stores/list` - List all stores with configuration
319+
- `stores/get <id>` - Get store by ID
320+
- `stores/update <id>` - Update store settings
321+
262322
For detailed documentation on each tool, see the [SKILLS documentation](./SKILLS/).
263323

264324
## Development

SKILLS/SKILL.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: Craft CMS Skills
3-
description: Complete skill suite for managing Craft CMS content including sections, entry types, fields, entries, drafts, field layouts, and sites.
3+
description: Complete skill suite for managing Craft CMS content including users, addresses, sections, entry types, fields, entries, drafts, field layouts, sites, and Commerce products, variants, and orders.
44
---
55

66
## Important: Use this plugin, Not YAML Files
@@ -80,5 +80,58 @@ All API endpoints:
8080
- [delete_asset](delete_asset.md) - `DELETE /api/assets/<id>` - Delete asset and file
8181
- [get_volumes](get_volumes.md) - `GET /api/volumes` - List asset volumes with IDs/URLs
8282

83+
## Addresses
84+
- [get_addresses](get_addresses.md) - `GET /api/addresses` - List/search addresses by owner, field, and location
85+
- [get_address](get_address.md) - `GET /api/addresses/<id>` - Retrieve address details with owner and field context
86+
- [create_address](create_address.md) - `POST /api/addresses` - Create generic owner-backed addresses for users or custom address fields
87+
- [update_address](update_address.md) - `PUT /api/addresses/<id>` - Update address attributes and custom fields
88+
- [delete_address](delete_address.md) - `DELETE /api/addresses/<id>` - Delete address (soft/permanent)
89+
- [get_address_field_layout](get_address_field_layout.md) - `GET /api/addresses/field-layout` - Retrieve the single global address field layout
90+
91+
## Users
92+
- [get_users](get_users.md) - `GET /api/users` - List/search users by query, identity fields, status, and optionally group
93+
- [get_user](get_user.md) - `GET /api/users/<id>` - Retrieve a user by ID, email, or username
94+
- [create_user](create_user.md) - `POST /api/users` - Create a user with native attributes and custom fields
95+
- [get_available_permissions](get_available_permissions.md) - `GET /api/users/permissions` - List all known permissions plus custom stored permission names
96+
- [update_user](update_user.md) - `PUT /api/users/<id>` - Update a user by ID, email, or username
97+
- [delete_user](delete_user.md) - `DELETE /api/users/<id>` - Delete a user by ID, email, or username
98+
- [get_user_field_layout](get_user_field_layout.md) - `GET /api/users/field-layout` - Retrieve the single global user field layout
99+
100+
## User Groups
101+
- [get_user_groups](get_user_groups.md) - `GET /api/user-groups` - List user groups and their permissions
102+
- [get_user_group](get_user_group.md) - `GET /api/user-groups/<id>` - Retrieve a user group by ID or handle
103+
- [create_user_group](create_user_group.md) - `POST /api/user-groups` - Create a user group and set permissions
104+
- [update_user_group](update_user_group.md) - `PUT /api/user-groups/<id>` - Update a user group and its permissions
105+
- [delete_user_group](delete_user_group.md) - `DELETE /api/user-groups/<id>` - Delete a user group by ID or handle
106+
83107
## System
84108
- [health](health.md) - `GET /api/health` - Health check endpoint to verify plugin installation and API availability
109+
110+
## Commerce: Products
111+
- [create_product](create_product.md) - `POST /api/products` - Create product with type, title, SKU, price, and custom fields
112+
- [get_product](get_product.md) - `GET /api/products/<id>` - Retrieve product with variants, pricing, and custom fields
113+
- [get_products](get_products.md) - `GET /api/products/search` - Search/filter products by type/status/query
114+
- [update_product](update_product.md) - `PUT /api/products/<id>` - Update product attributes and custom fields
115+
- [delete_product](delete_product.md) - `DELETE /api/products/<id>` - Delete product (soft/permanent)
116+
- [get_product_types](get_product_types.md) - `GET /api/product-types` - List available Commerce product types
117+
- [get_product_type](get_product_type.md) - `GET /api/product-types/<id>` - Retrieve product type with field layouts and site settings
118+
- [create_product_type](create_product_type.md) - `POST /api/product-types` - Create product type with title, variant, layout, and site settings
119+
- [update_product_type](update_product_type.md) - `PUT /api/product-types/<id>` - Update product type configuration and site settings
120+
- [delete_product_type](delete_product_type.md) - `DELETE /api/product-types/<id>` - Delete product type with impact analysis and force protection
121+
122+
## Commerce: Variants
123+
- [create_variant](create_variant.md) - `POST /api/variants` - Add variant to existing product with SKU, price, and attributes
124+
- [get_variant](get_variant.md) - `GET /api/variants/<id>` - Retrieve variant with pricing, inventory, and dimensions
125+
- [update_variant](update_variant.md) - `PUT /api/variants/<id>` - Update variant pricing, SKU, stock, and fields
126+
- [delete_variant](delete_variant.md) - `DELETE /api/variants/<id>` - Delete variant (soft/permanent)
127+
128+
## Commerce: Orders
129+
- [get_order](get_order.md) - `GET /api/orders/<id>` - Retrieve order with line items, totals, and addresses
130+
- [search_orders](search_orders.md) - `GET /api/orders/search` - Search/filter orders by email/status/date/payment
131+
- [update_order](update_order.md) - `PUT /api/orders/<id>` - Update order status or message
132+
- [get_order_statuses](get_order_statuses.md) - `GET /api/order-statuses` - List all order statuses with IDs/handles/colors
133+
134+
## Commerce: Stores
135+
- [get_stores](get_stores.md) - `GET /api/stores` - List all stores with checkout/payment/tax configuration
136+
- [get_store](get_store.md) - `GET /api/stores/<id>` - Retrieve store with full configuration details
137+
- [update_store](update_store.md) - `PUT /api/stores/<id>` - Update store checkout, payment, and pricing settings

SKILLS/create_address.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# create_address
2+
3+
Create an Address for a generic owner, either directly on an element or inside an `Addresses` custom field.
4+
5+
## Endpoint
6+
7+
`POST /api/addresses`
8+
9+
## Parameters
10+
11+
- `ownerId` (int, required) - Owner element ID
12+
- `ownerType` (string, required) - Owner element class name
13+
- `fieldId` (int, optional) - Target `craft\fields\Addresses` field ID
14+
- `fieldHandle` (string, optional) - Alternative to `fieldId`
15+
- Native address attributes such as `title`, `countryCode`, `administrativeArea`, `locality`, `postalCode`, `addressLine1`, `addressLine2`, `organization`, `latitude`, `longitude`
16+
- `fields` (object, optional) - Custom address field values from the global Address field layout
17+
18+
## Returns
19+
20+
Returns the created address with ownership metadata and serialized custom fields.
21+
22+
## Example
23+
24+
```json
25+
{
26+
"ownerId": 12,
27+
"ownerType": "craft\\elements\\User",
28+
"title": "Home",
29+
"countryCode": "US",
30+
"addressLine1": "123 Main St",
31+
"locality": "Portland",
32+
"administrativeArea": "OR",
33+
"postalCode": "97205"
34+
}
35+
```

SKILLS/create_product.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# create_product
2+
3+
Create a new Commerce product with a default variant.
4+
5+
## Route
6+
7+
`POST /api/products`
8+
9+
## Description
10+
11+
Creates a new Commerce product with the specified product type, title, and default variant (SKU and price). The product is created with a single default variant; use `create_variant` to add additional variants after creation.
12+
13+
## Parameters
14+
15+
### Required Parameters
16+
17+
- **typeId** (integer): The product type ID. Use `get_product_types` to discover available types.
18+
- **title** (string): Product title.
19+
- **sku** (string): SKU for the default variant.
20+
- **price** (float): Price for the default variant.
21+
22+
### Optional Parameters
23+
24+
- **slug** (string, optional): Product slug. Auto-generated from title if not provided.
25+
- **postDate** (string, optional): Post date in ISO 8601 format. Defaults to now.
26+
- **expiryDate** (string, optional): Expiry date in ISO 8601 format. Null means no expiry.
27+
- **enabled** (boolean, optional): Whether the product is enabled. Default: `true`.
28+
- **fields** (object, optional): Custom field data keyed by field handle.
29+
30+
## Return Value
31+
32+
Returns an object containing:
33+
34+
- **_notes** (string): Confirmation message
35+
- **productId** (integer): Created product ID
36+
- **title** (string): Product title
37+
- **slug** (string): Product slug
38+
- **status** (string): Product status (live, pending, expired, disabled)
39+
- **typeId** (integer): Product type ID
40+
- **typeName** (string): Product type name
41+
- **defaultSku** (string): Default variant SKU
42+
- **defaultPrice** (float): Default variant price
43+
- **url** (string): Craft control panel edit URL
44+
45+
## Example Usage
46+
47+
### Basic Product
48+
```json
49+
{
50+
"typeId": 1,
51+
"title": "Ergonomic Widget",
52+
"sku": "WIDGET-001",
53+
"price": 29.99
54+
}
55+
```
56+
57+
### Product with All Options
58+
```json
59+
{
60+
"typeId": 1,
61+
"title": "Premium Widget",
62+
"sku": "WIDGET-PRE-001",
63+
"price": 99.99,
64+
"slug": "premium-widget",
65+
"postDate": "2025-06-01T00:00:00+00:00",
66+
"expiryDate": "2025-12-31T23:59:59+00:00",
67+
"enabled": true,
68+
"fields": {
69+
"description": "A premium ergonomic widget."
70+
}
71+
}
72+
```
73+
74+
### CLI Usage
75+
```bash
76+
agent-craft products/create --typeId=1 --title="Ergonomic Widget" --sku="WIDGET-001" --price=29.99
77+
agent-craft products/create --typeId=1 --title="Premium Widget" --sku="WIDGET-PRE" --price=99.99 --slug="premium-widget" --enabled=false
78+
```
79+
80+
## Notes
81+
82+
- A default variant is always created with the provided SKU and price
83+
- Use `get_product_types` to discover available product type IDs
84+
- Use `create_variant` to add additional variants after creation
85+
- Throws an error if the product type ID is invalid
86+
- Requires Craft Commerce to be installed
87+
88+
## See Also
89+
90+
- [get_product_types](get_product_types.md) - Discover available product types
91+
- [update_product](update_product.md) - Update product attributes
92+
- [create_variant](create_variant.md) - Add variants to a product

0 commit comments

Comments
 (0)