fluentcart-products-inventory
Implements and audits FluentCart products, details, variations, pricing, custom attributes, taxonomies, downloadable flags, bundles, and stock movements. Use when creating or updating fluent-products records, calling ProductResource or ProductVariationResource, adding variation t
Install
npx skills add https://github.com/Lonsdale201/wp-agent-skills/tree/main/fluentcart/fluentcart-products-inventory
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install lonsdale201-wp-agent-skills@llmmart
git clone https://github.com/Lonsdale201/wp-agent-skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole lonsdale201/wp-agent-skills collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
FluentCart products and inventory
Maintain the whole product aggregate: WordPress post, product detail, variants, attribute relations, media/download data, tax/shipping configuration, and stock.
Read product-contract.md before implementing a writer, importer, bundle, custom variation type, or inventory sync.
Understand the aggregate
- Product is a model over wp_posts and is globally scoped to post type fluent-products.
- ProductDetail and ProductVariation live in fct_product_details and fct_product_variations.
- Categories and brands are WP taxonomies product-categories and product-brands.
- Variant attributes use FluentCart's fct_attribute_* tables. Do not model them as WordPress terms.
- A variation ID is the purchasable object_id used by cart/order items. Do not substitute the parent product ID.
- Prices remain minor-unit values even though variation price columns and ORM casts are double.
Write through coordinated APIs
Prefer ProductResource and ProductVariationResource for product-editor-like mutations. Use Taxonomy for FluentCart taxonomy synchronization. Use native WordPress post functions only when the change truly affects only post fields.
Do not create a complete product with wp_insert_post() alone. It leaves detail, variation, pricing, and relationship rows absent. Do not update stock columns independently; available, on_hold, committed, total_stock, stock_status, and the product-level stock availability must stay coherent.
For batch import:
- Normalize all amounts to integer minor units.
- Create or map product posts.
- create details and variants through Resource/service code;
- map custom attributes separately from WP taxonomies;
- attach downloads/media;
- validate SKU uniqueness and purchasability;
- dispatch or reproduce the normal product/variation change path;
- verify counts and orphan rows after the batch.
Observe the right event
| Need | Hook/event |
|---|---|
| General product save | fluent_cart/product_updated |
| Product editor variant save | fluent_cart/product/variants_updated |
| Variant set changed and default may be invalid | fluent_cart/product_variations_changed |
| Stock changed | fluent_cart/product_stock_changed |
| Extend supported variation types | fluent_cart/variation_types |
| Adjust data accepted during variant save | fluent_cart/product/variant_save_data |
Do not use a display/render hook as a durable catalog event. Scope callbacks by post ID and make external synchronization replay-safe.
Inventory rules
- Check ProductVariation::canPurchase() or the normal cart validation path before accepting a quantity.
- Honor sold_individually, manage_stock, backorders, item_status, parent publish status, and bundle-child availability.
- Let StockManagement react to order lifecycle events. It moves units between available, on_hold, and committed and records order meta stock_movement.
- Do not reduce stock again on order_paid if order_created already reserved it.
- Test status reversals, refunds, canceled/failed orders, physical delivery, digital orders, bundles, and repeated events.
- Feature-detect the stock_management module; its advanced behavior can be off.
Query efficiently
- Eager-load detail and variants when rendering lists.
- Query product posts through Product/ProductResource, not WP_Query plus one custom query per row.
- Avoid hydrating every variant for ID/count-only jobs.
- Bound batch size and advance by a stable numeric ID for long-running work.
- Keep test/live reporting filters when product statistics join orders.
Free/Pro boundary
The product, variant, custom attribute, stock, download, and recurring-plan base models are Free in 1.6.0. Pro adds installments and promotional/order-bump features; do not make all subscription-priced products or all promotions Pro-only.
Cross-references
- Use fluentcart-cart-checkout for purchasability and custom cart items.
- Use fluentcart-downloads-storage for downloadable files.
- Use fluentcart-shipping-tax for class and tax behavior.
References
- Official model documentation: https://dev.fluentcart.com/database/models/
- Verified Free source paths:
- fluent-cart/app/CPT/FluentProducts.php
- fluent-cart/app/Models/Product.php
- fluent-cart/app/Models/ProductDetail.php
- fluent-cart/app/Models/ProductVariation.php
- fluent-cart/api/Resource/ProductResource.php
- fluent-cart/api/Resource/ProductVariationResource.php
- fluent-cart/api/Taxonomy.php
- fluent-cart/app/Modules/StockManagement/StockManagement.php
- fluent-cart/app/Events/ProductVariationsChanged.php
- fluent-cart/app/Events/StockChanged.php
Files (wp-agent-skills)
-
agents
-
openai.yaml 307 B
interface: display_name: "FluentCart products and inventory" short_description: "Keep products, variants, pricing, and stock coherent" default_prompt: "Use $fluentcart-products-inventory to implement or audit this FluentCart catalog or inventory change without desynchronizing the product aggregate."
-
-
references
-
product-contract.md 2.4 KB
# FluentCart 1.6.0 product contract ## Identifiers and storage | Value | Meaning | |---|---| | Product.ID / post_id | WordPress post ID for fluent-products | | ProductDetail.id | Internal detail row ID | | ProductVariation.id | Purchasable variant ID used as cart/order object_id | | variation_identifier | Combination identity, not the primary key | | sku | Globally unique non-null SKU; maximum 30 chars in 1.6.0 | ProductVariation includes item_price, compare_price, item_cost, payment_type, fulfillment_type, item_status, sold_individually, downloadable, shipping_class, stock fields, and other_info. ## Taxonomy versus attribute data Use WP taxonomy APIs for: - product-categories - product-brands Use FluentCart attribute resources/tables for configurable variation groups, terms, mappings, and relations. A WordPress category/brand term is not a variant attribute term. ## Pricing and recurring metadata - Treat item_price, compare_price, item_cost, setup fees, and recurring amounts as minor units. - payment_type distinguishes onetime and subscription behavior. - Subscription terms such as repeat_interval, times, trial_days, and setup-fee flags are stored in variation other_info. - ProductVariation normalizes installment to no when Pro is unavailable. ## Inventory state | Field | Role | |---|---| | total_stock | configured total | | available | currently available to reserve | | on_hold | reserved by placed, unfulfilled order state | | committed | fulfilled/committed stock | | stock_status | in-stock or out-of-stock projection | | manage_stock | whether the variant participates | | backorders | whether normal stock shortage can be bypassed | The StockManagement module reacts to order_created, order_paid, order_refunded, order_updated, order_status_changed, and shipping_status_changed. Its callbacks are stateful and use order stock_movement meta. Never emulate one callback by blind arithmetic. ## Verification matrix Test: 1. simple one-time digital, physical, and service variants; 2. subscription and setup-fee variants; 3. globally duplicated SKU; 4. unpublished product or inactive variation; 5. sold-individually and quantity greater than one; 6. managed stock at zero, backorder mode, and a status reversal; 7. bundle parent with an unavailable child; 8. detail/variant deletion and default-variation repair; 9. categories/brands versus custom attributes; 10. product list queries with bounded eager loading.
-
-
SKILL.md 5.4 KB
--- name: fluentcart-products-inventory description: >- Implements and audits FluentCart products, details, variations, pricing, custom attributes, taxonomies, downloadable flags, bundles, and stock movements. Use when creating or updating fluent-products records, calling ProductResource or ProductVariationResource, adding variation types, syncing product-categories or product-brands, reacting to product_updated, product_variations_changed, product_stock_changed, or preventing direct fct_product_* writes from desynchronizing inventory. metadata: wp-skills-author: "Soczó Kristóf" wp-skills-contact: "mailto:lonsdale201@hotmail.com" wp-skills-plugin: "fluent-cart" wp-skills-plugin-version-tested: "1.6.0" wp-skills-wp-version-tested: "7.0.2" wp-skills-php-min: "7.4" wp-skills-last-updated: "2026-08-06" --- # FluentCart products and inventory Maintain the whole product aggregate: WordPress post, product detail, variants, attribute relations, media/download data, tax/shipping configuration, and stock. Read [product-contract.md](references/product-contract.md) before implementing a writer, importer, bundle, custom variation type, or inventory sync. ## Understand the aggregate - Product is a model over wp_posts and is globally scoped to post type fluent-products. - ProductDetail and ProductVariation live in fct_product_details and fct_product_variations. - Categories and brands are WP taxonomies product-categories and product-brands. - Variant attributes use FluentCart's fct_attribute_* tables. Do not model them as WordPress terms. - A variation ID is the purchasable object_id used by cart/order items. Do not substitute the parent product ID. - Prices remain minor-unit values even though variation price columns and ORM casts are double. ## Write through coordinated APIs Prefer ProductResource and ProductVariationResource for product-editor-like mutations. Use Taxonomy for FluentCart taxonomy synchronization. Use native WordPress post functions only when the change truly affects only post fields. Do not create a complete product with wp_insert_post() alone. It leaves detail, variation, pricing, and relationship rows absent. Do not update stock columns independently; available, on_hold, committed, total_stock, stock_status, and the product-level stock availability must stay coherent. For batch import: 1. Normalize all amounts to integer minor units. 2. Create or map product posts. 3. create details and variants through Resource/service code; 4. map custom attributes separately from WP taxonomies; 5. attach downloads/media; 6. validate SKU uniqueness and purchasability; 7. dispatch or reproduce the normal product/variation change path; 8. verify counts and orphan rows after the batch. ## Observe the right event | Need | Hook/event | |---|---| | General product save | fluent_cart/product_updated | | Product editor variant save | fluent_cart/product/variants_updated | | Variant set changed and default may be invalid | fluent_cart/product_variations_changed | | Stock changed | fluent_cart/product_stock_changed | | Extend supported variation types | fluent_cart/variation_types | | Adjust data accepted during variant save | fluent_cart/product/variant_save_data | Do not use a display/render hook as a durable catalog event. Scope callbacks by post ID and make external synchronization replay-safe. ## Inventory rules - Check ProductVariation::canPurchase() or the normal cart validation path before accepting a quantity. - Honor sold_individually, manage_stock, backorders, item_status, parent publish status, and bundle-child availability. - Let StockManagement react to order lifecycle events. It moves units between available, on_hold, and committed and records order meta stock_movement. - Do not reduce stock again on order_paid if order_created already reserved it. - Test status reversals, refunds, canceled/failed orders, physical delivery, digital orders, bundles, and repeated events. - Feature-detect the stock_management module; its advanced behavior can be off. ## Query efficiently - Eager-load detail and variants when rendering lists. - Query product posts through Product/ProductResource, not WP_Query plus one custom query per row. - Avoid hydrating every variant for ID/count-only jobs. - Bound batch size and advance by a stable numeric ID for long-running work. - Keep test/live reporting filters when product statistics join orders. ## Free/Pro boundary The product, variant, custom attribute, stock, download, and recurring-plan base models are Free in 1.6.0. Pro adds installments and promotional/order-bump features; do not make all subscription-priced products or all promotions Pro-only. ## Cross-references - Use fluentcart-cart-checkout for purchasability and custom cart items. - Use fluentcart-downloads-storage for downloadable files. - Use fluentcart-shipping-tax for class and tax behavior. ## References - Official model documentation: <https://dev.fluentcart.com/database/models/> - Verified Free source paths: - fluent-cart/app/CPT/FluentProducts.php - fluent-cart/app/Models/Product.php - fluent-cart/app/Models/ProductDetail.php - fluent-cart/app/Models/ProductVariation.php - fluent-cart/api/Resource/ProductResource.php - fluent-cart/api/Resource/ProductVariationResource.php - fluent-cart/api/Taxonomy.php - fluent-cart/app/Modules/StockManagement/StockManagement.php - fluent-cart/app/Events/ProductVariationsChanged.php - fluent-cart/app/Events/StockChanged.php
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.