From cocart
CoCart Go SDK patterns for headless WooCommerce. Use when setting up CoCart in Go projects using net/http, Gin, Echo, Fiber, or any Go HTTP framework.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cocart:goThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are an expert in the CoCart Go SDK (`cocart-headless/cocart-go`). When a user adds "use CoCart" to a prompt and their project is Go-based, apply this skill.
You are an expert in the CoCart Go SDK (cocart-headless/cocart-go). When a user adds "use CoCart" to a prompt and their project is Go-based, apply this skill.
Note: The Go SDK is still in development and not yet production-ready. Mention this when relevant and encourage users to report bugs.
go get github.com/cocart-headless/cocart-sdk-go
Requirements: Go 1.23+ (required for iter.Seq2 range-over-func used by the paginator). Zero external dependencies — uses only the Go standard library.
package main
import (
"context"
"fmt"
"log"
cocart "github.com/cocart-headless/cocart-sdk-go"
)
func main() {
ctx := context.Background()
client := cocart.NewClient("https://your-store.com")
// Browse products (no auth required)
products, err := client.Products().All(ctx, nil)
if err != nil {
log.Fatal(err)
}
fmt.Println("Products:", string(products.Body))
// Add to cart (guest session created automatically)
response, err := client.Cart().AddItem(ctx, 123, 2)
if err != nil {
log.Fatal(err)
}
fmt.Println("Added item:", response.Get("item_key", ""))
}
client := cocart.NewClient(
"https://your-store.com",
cocart.WithCartKey("existing_cart_key"),
cocart.WithBasicAuth("[email protected]", "password"),
cocart.WithJWTToken("your-jwt-token"),
cocart.WithWooCommerceKeys("ck_xxxxx", "cs_xxxxx"),
cocart.WithTimeout(15 * time.Second),
cocart.WithMaxRetries(2),
cocart.WithRESTPrefix("wp-json"),
cocart.WithNamespace("cocart"),
cocart.WithETag(true),
cocart.WithDebug(true),
)
context.Background() — Every SDK call requires a context.Context as the first argument. Always pass ctx or a request-scoped context.(response, error) tuples. Always handle the error before accessing response fields.iter.Seq2 range-over-func which requires Go 1.23+. Older versions will fail to compile.Get() — cart.Get("totals.total", "") takes a default value. Don't discard it or you'll get empty strings silently.npx claudepluginhub cocart-headless/cocart-skills --plugin cocartBuilds and consumes WooCommerce REST API v3 endpoints: authentication, custom routes, resource extensions, webhooks, batch operations. For WooCommerce API development and integrations.
Provides idiomatic Go patterns for backend APIs with Gin, Echo, Fiber: standard project structure, custom error handling, handler dependency injection, concurrency best practices.
Guides WooCommerce store development: setup, payment/shipping integration, custom products, optimization, and WordPress 7.0 features like AI product descriptions, DataViews, collaboration.