You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,15 +59,15 @@ You can read more about it on `./ARCHITECTURE.md`, but here’s a high-level ove
59
59
60
60
`woocommerce-product-addon.php` — defines constants, loads Composer autoload, manually `require_once`s all class/include files (no PSR-4 autoloading for plugin code), then hooks `PPOM()` on `woocommerce_init`.
61
61
62
-
### Core Classes (all singleton pattern via `get_instance()`)
62
+
### Core Classes
63
63
64
64
| Class | File | Role |
65
65
|---|---|---|
66
66
|`NM_PersonalizedProduct`|`classes/plugin.class.php`| Main plugin — registers all WooCommerce hooks, loads input types |
67
-
|`NM_PersonalizedProduct_Admin`|`classes/admin.class.php`| Admin-only — loaded only in `is_admin()`|
68
-
|`PPOM_Meta`|`classes/ppom.class.php`|Field group CRUD against custom DB table |
67
+
|`NM_PersonalizedProduct_Admin`|`classes/admin.class.php`| Admin-only coordinator for menus, settings, attach flows, and admin AJAX|
68
+
|`PPOM_Meta`|`classes/ppom.class.php`|Product-side field-group resolver that reads attached groups and loads settings/fields from the custom DB table |
69
69
|`PPOM_Form`|`classes/form.class.php`| Frontend form rendering |
70
-
|`PPOM_Fields_Meta`|`classes/fields.class.php`|Field type registry and metadata|
70
+
|`PPOM_Fields_Meta`|`classes/fields.class.php`|Admin field-builder UI, modals, and builder asset loading|
71
71
|`PPOM_Inputs`|`classes/input.class.php`| Input type manager |
| Main runtime |[`classes/plugin.class.php`](/Users/robert/Desktop/sites/plugins-dev/web/app/plugins/woocommerce-product-addon/classes/plugin.class.php)| Registers WooCommerce hooks for rendering, validation, pricing, cart, orders, admin AJAX, cron, and loop behavior |
67
-
| Product field resolver |[`classes/ppom.class.php`](/Users/robert/Desktop/sites/plugins-dev/web/app/plugins/woocommerce-product-addon/classes/ppom.class.php)| Resolves applicable PPOM field groups for a product and loads settings and fields from the custom DB table |
67
+
| Product field resolver |[`classes/ppom.class.php`](/Users/robert/Desktop/sites/plugins-dev/web/app/plugins/woocommerce-product-addon/classes/ppom.class.php)| Resolves applicable PPOM field groups for a product, merges their fields, and derives the runtime settings row from the custom DB table |
68
68
| Frontend form renderer |[`classes/form.class.php`](/Users/robert/Desktop/sites/plugins-dev/web/app/plugins/woocommerce-product-addon/classes/form.class.php)| Renders modern template-based product fields and hidden runtime state |
| Admin field UI |[`classes/fields.class.php`](/Users/robert/Desktop/sites/plugins-dev/web/app/plugins/woocommerce-product-addon/classes/fields.class.php)| Powers the field-group builder UI and admin-side assets |
| Frontend asset loader |[`classes/frontend-scripts.class.php`](/Users/robert/Desktop/sites/plugins-dev/web/app/plugins/woocommerce-product-addon/classes/frontend-scripts.class.php)| Registers and localizes frontend JS and CSS for pricing, uploads, validation, conditions, and field widgets |
73
+
| Script registry |[`classes/scripts.class.php`](/Users/robert/Desktop/sites/plugins-dev/web/app/plugins/woocommerce-product-addon/classes/scripts.class.php)| Shared wrapper for registering, enqueuing, localizing, and inlining PPOM frontend assets |
@@ -88,7 +90,7 @@ Each row contains both group-level settings and the full field definition payloa
88
90
-`productmeta_style`
89
91
-`productmeta_js`
90
92
-`productmeta_categories`
91
-
-`productmeta_tags`
93
+
-`productmeta_tags` when extensions or add-ons use tag-aware assignment
92
94
-`the_meta` as JSON
93
95
94
96
Products are linked to PPOM groups through the normal post meta key:
@@ -97,14 +99,14 @@ Products are linked to PPOM groups through the normal post meta key:
97
99
98
100
That value may contain one or more field-group IDs.
99
101
100
-
`PPOM_Meta` is the resolution layer. For a given product, it:
102
+
`PPOM_Meta` is the read-side resolution layer. For a given product, it:
101
103
102
104
1. reads `_product_meta_id`
103
105
2. checks category-linked groups
104
106
3. merges or overrides group IDs through filters
105
107
4. loads the matching row or rows from the custom table
106
-
5.decodes `the_meta` into the active field list
107
-
6.exposes group settings such as inline CSS, inline JS, price-display mode, and group title
108
+
5.merges field definitions from all matched groups
109
+
6.derives one active settings row for runtime values such as inline CSS, inline JS, price-display mode, and group title
108
110
109
111
```mermaid
110
112
flowchart TD
@@ -116,8 +118,8 @@ flowchart TD
116
118
E --> F["Apply merge / override filters"]
117
119
F --> G["Load rows from {prefix}_nm_personalized"]
118
120
G --> H["Decode the_meta JSON"]
119
-
H --> I["Active PPOM fields"]
120
-
H --> J["Group settings"]
121
+
H --> I["Merged active PPOM fields"]
122
+
H --> J["Derived runtime settings row"]
121
123
I --> K["Frontend rendering"]
122
124
I --> L["Validation and pricing lookup"]
123
125
J --> M["Inline CSS / JS / display mode"]
@@ -220,7 +222,7 @@ The modern path renders:
220
222
221
223
- the active field groups
222
224
- a price-table container
223
-
- hidden inputs for group IDs, current product ID, option-price state, conditional-hide state, and cart-edit state
225
+
- hidden inputs and wrapper state through `PPOM_Form::form_contents()`
224
226
225
227
That hidden form state is what keeps the frontend JS and backend PHP in sync.
226
228
@@ -361,12 +363,14 @@ The admin side has two main responsibilities:
361
363
- field-group CRUD
362
364
- settings and permissions
363
365
364
-
Field-group management is provided by`NM_PersonalizedProduct_Admin`, `PPOM_Fields_Meta`, and the AJAX CRUD handlers in [`inc/admin.php`](/Users/robert/Desktop/sites/plugins-dev/web/app/plugins/woocommerce-product-addon/inc/admin.php). That layer lets admins:
366
+
Field-group management is split across`NM_PersonalizedProduct_Admin`, `PPOM_Fields_Meta`, and the AJAX CRUD handlers in [`inc/admin.php`](/Users/robert/Desktop/sites/plugins-dev/web/app/plugins/woocommerce-product-addon/inc/admin.php):
365
367
366
368
- create, edit, clone, and delete field groups
367
369
- bulk-attach field groups to products
368
370
- choose which group is attached on the product edit screen
369
371
372
+
`PPOM_Meta` is not the CRUD layer. It resolves product-side field groups and reads their settings/fields at runtime.
373
+
370
374
Settings use two storage models:
371
375
372
376
- legacy WooCommerce settings-tab storage
@@ -435,7 +439,7 @@ The API supports:
435
439
- updating order PPOM metadata
436
440
- deleting order PPOM metadata
437
441
438
-
The important implementation detail is that the routes use open permission callbacks, but write operations validate a PPOM secret key inside the handler. That makes the API optional and configuration-gated, but still part of the plugin's public integration surface.
442
+
The important implementation detail is that the routes use open permission callbacks, while write operations validate a PPOM secret key inside the handler. That makes the API optional and configuration-gated, but still part of the plugin's public integration surface.
439
443
440
444
## Extension and Compatibility Model
441
445
@@ -473,7 +477,7 @@ PPOM stores data in several WordPress and WooCommerce persistence layers.
473
477
### Custom database table
474
478
475
479
-`{prefix}_nm_personalized`
476
-
Stores PPOM field-group definitions and group-level settings such as `productmeta_name`, `dynamic_price_display`, `productmeta_style`, `productmeta_js`, category/tag assignment, and `the_meta` JSON.
480
+
Stores PPOM field-group definitions and group-level settings such as `productmeta_name`, `dynamic_price_display`, `productmeta_style`, `productmeta_js`, category assignment, optional tag data for extensions/add-ons, and `the_meta` JSON.
0 commit comments