PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.0.1
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.0.1
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / docs / wiki / AJAX-API-Reference.md

AJAX-API-Reference.md in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.0.1, at docs/wiki/AJAX-API-Reference.md

394 lines 10.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 # AJAX API Reference
2
3 CartFlows handles many admin operations via WordPress AJAX (`admin-ajax.php`). All actions use the prefix `cartflows_` and require nonce verification.
4
5 ## AJAX Pattern
6
7 All AJAX handlers extend `AjaxBase` (`admin-core/ajax/ajax-base.php`). The base class:
8 - Registers `wp_ajax_cartflows_{action}` hooks automatically via `init_ajax_events()`
9 - Generates and localises nonces for each action
10 - Provides `AjaxErrors::get_instance()` for standardised error messages
11
12 **Request format:**
13
14 ```js
15 // JavaScript (jQuery)
16 $.ajax( {
17 url: wcfEditorAppData.ajax_url,
18 method: 'POST',
19 data: {
20 action: 'cartflows_clone_flow',
21 security: wcfEditorAppData.nonces.clone_flow,
22 flow_id: 123,
23 }
24 } );
25 ```
26
27 **Response format:**
28
29 ```json
30 // Success
31 { "success": true, "data": { ... } }
32
33 // Error
34 { "success": false, "data": { "messsage": "Error description" } }
35 ```
36
37 ## Custom Capabilities
38
39 | Capability | Required for |
40 |-----------|-------------|
41 | `cartflows_manage_flows_steps` | All flow and step operations |
42 | `cartflows_manage_settings` | Global settings operations |
43
44 ---
45
46 ## Flows AJAX (`admin-core/ajax/flows.php`)
47
48 **Class:** `CartflowsAdmin\AdminCore\Ajax\Flows`
49
50 ### `cartflows_update_flow_title`
51
52 Update a flow's title.
53
54 | Parameter | Type | Description |
55 |-----------|------|-------------|
56 | `security` | string | Nonce: `cartflows_update_flow_title` |
57 | `flow_id` | int | Flow post ID |
58 | `flow_title` | string | New title |
59
60 ---
61
62 ### `cartflows_clone_flow`
63
64 Duplicate a flow along with all its steps and post meta.
65
66 | Parameter | Type | Description |
67 |-----------|------|-------------|
68 | `security` | string | Nonce: `cartflows_clone_flow` |
69 | `flow_id` | int | Flow post ID to clone |
70
71 **Returns:** New flow ID and redirect URL.
72
73 ---
74
75 ### `cartflows_delete_flow`
76
77 Permanently delete a flow and all associated steps.
78
79 | Parameter | Type | Description |
80 |-----------|------|-------------|
81 | `security` | string | Nonce: `cartflows_delete_flow` |
82 | `flow_id` | int | Flow post ID |
83
84 ---
85
86 ### `cartflows_trash_flow`
87
88 Move a flow to trash (soft delete; recoverable).
89
90 | Parameter | Type | Description |
91 |-----------|------|-------------|
92 | `security` | string | Nonce: `cartflows_trash_flow` |
93 | `flow_id` | int | Flow post ID |
94
95 ---
96
97 ### `cartflows_restore_flow`
98
99 Restore a trashed flow to its previous status.
100
101 | Parameter | Type | Description |
102 |-----------|------|-------------|
103 | `security` | string | Nonce: `cartflows_restore_flow` |
104 | `flow_id` | int | Flow post ID |
105
106 ---
107
108 ### `cartflows_reorder_flow_steps`
109
110 Reorder steps within a flow (drag-and-drop save).
111
112 | Parameter | Type | Description |
113 |-----------|------|-------------|
114 | `security` | string | Nonce: `cartflows_reorder_flow_steps` |
115 | `flow_id` | int | Flow post ID |
116 | `steps` | array | Array of step IDs in new order |
117
118 ---
119
120 ### `cartflows_trash_flows_in_bulk`
121
122 Move multiple flows to trash in a single request.
123
124 | Parameter | Type | Description |
125 |-----------|------|-------------|
126 | `security` | string | Nonce: `cartflows_trash_flows_in_bulk` |
127 | `flow_ids` | array | Array of flow post IDs |
128
129 ---
130
131 ### `cartflows_update_flow_post_status`
132
133 Change the status (publish/draft) for multiple flows.
134
135 | Parameter | Type | Description |
136 |-----------|------|-------------|
137 | `security` | string | Nonce: `cartflows_update_flow_post_status` |
138 | `flow_ids` | array | Array of flow post IDs |
139 | `status` | string | `publish` or `draft` |
140
141 ---
142
143 ### `cartflows_delete_flows_permanently`
144
145 Permanently delete multiple flows (cannot be undone).
146
147 | Parameter | Type | Description |
148 |-----------|------|-------------|
149 | `security` | string | Nonce: `cartflows_delete_flows_permanently` |
150 | `flow_ids` | array | Array of flow post IDs |
151
152 ---
153
154 ### `cartflows_save_flow_meta_settings`
155
156 Save flow-level meta data and settings.
157
158 | Parameter | Type | Description |
159 |-----------|------|-------------|
160 | `security` | string | Nonce: `cartflows_save_flow_meta_settings` |
161 | `flow_id` | int | Flow post ID |
162 | `settings` | object | Flow settings key-value pairs |
163
164 ---
165
166 ### `cartflows_export_flows_in_bulk`
167
168 Export one or more flows as a JSON file for download.
169
170 | Parameter | Type | Description |
171 |-----------|------|-------------|
172 | `security` | string | Nonce: `cartflows_export_flows_in_bulk` |
173 | `flow_ids` | array | Array of flow post IDs |
174
175 ---
176
177 ### `cartflows_update_status`
178
179 Update the status of a flow or step.
180
181 | Parameter | Type | Description |
182 |-----------|------|-------------|
183 | `security` | string | Nonce: `cartflows_update_status` |
184 | `id` | int | Post ID (flow or step) |
185 | `status` | string | New status (`publish`, `draft`) |
186
187 ---
188
189 ### `cartflows_update_store_checkout_status`
190
191 Enable or disable the global store checkout feature.
192
193 | Parameter | Type | Description |
194 |-----------|------|-------------|
195 | `security` | string | Nonce: `cartflows_update_store_checkout_status` |
196 | `status` | string | `enable` or `disable` |
197
198 Fires the `cartflows_after_save_store_checkout` action after saving.
199
200 ---
201
202 ### `cartflows_hide_instant_checkout_notice`
203
204 Dismiss the instant checkout admin notice for the current user.
205
206 | Parameter | Type | Description |
207 |-----------|------|-------------|
208 | `security` | string | Nonce: `cartflows_hide_instant_checkout_notice` |
209
210 ---
211
212 ### `cartflows_get_published_flows`
213
214 Retrieve a list of published flows (used in analytics dropdowns).
215
216 | Parameter | Type | Description |
217 |-----------|------|-------------|
218 | `security` | string | Nonce: `cartflows_get_published_flows` |
219
220 ---
221
222 ## Steps AJAX (`admin-core/ajax/steps.php`)
223
224 **Class:** `CartflowsAdmin\AdminCore\Ajax\Steps`
225
226 ### `cartflows_update_step_title`
227
228 Update a step's title.
229
230 | Parameter | Type | Description |
231 |-----------|------|-------------|
232 | `security` | string | Nonce: `cartflows_update_step_title` |
233 | `step_id` | int | Step post ID |
234 | `step_title` | string | New title |
235
236 ---
237
238 ### `cartflows_clone_step`
239
240 Duplicate a step within a flow (including all post meta).
241
242 | Parameter | Type | Description |
243 |-----------|------|-------------|
244 | `security` | string | Nonce: `cartflows_clone_step` |
245 | `step_id` | int | Step post ID |
246 | `flow_id` | int | Parent flow post ID |
247
248 Note: Cannot clone A/B test steps.
249
250 ---
251
252 ### `cartflows_delete_step`
253
254 Delete a step from a flow.
255
256 | Parameter | Type | Description |
257 |-----------|------|-------------|
258 | `security` | string | Nonce: `cartflows_delete_step` |
259 | `step_id` | int | Step post ID |
260 | `flow_id` | int | Parent flow post ID |
261
262 Note: A/B test steps use the `cartflows_step_delete_ab_test` action for special handling.
263
264 ---
265
266 ### `cartflows_save_meta_settings`
267
268 Save step meta settings (field configuration, layout, design).
269
270 | Parameter | Type | Description |
271 |-----------|------|-------------|
272 | `security` | string | Nonce: `cartflows_save_meta_settings` |
273 | `step_id` | int | Step post ID |
274 | `settings` | object | Step settings key-value pairs |
275
276 Fires `cartflows_admin_save_step_meta` action after saving. Also triggers dynamic CSS regeneration.
277
278 ---
279
280 ## Meta Data AJAX (`admin-core/ajax/meta-data.php`)
281
282 **Class:** `CartflowsAdmin\AdminCore\Ajax\MetaData`
283
284 ### `cartflows_json_search_products`
285
286 Search WooCommerce products by title term.
287
288 | Parameter | Type | Description |
289 |-----------|------|-------------|
290 | `security` | string | Nonce: `cartflows_json_search_products` |
291 | `term` | string | Product search term |
292 | `allowed_products` | array | Limit to specific product types |
293 | `include_products` | array | Include additional product type slugs |
294 | `exclude_products` | array | Exclude product type slugs |
295 | `display_stock` | bool | Include stock quantity in response |
296
297 **Supported product types (filterable):**
298
299 ```
300 simple, variable, variation, subscription,
301 variable-subscription, subscription_variation, course
302 ```
303
304 Filter: `cartflows_supported_product_types_for_search`
305
306 ---
307
308 ### `cartflows_json_search_coupons`
309
310 Search WooCommerce coupons by title/code.
311
312 | Parameter | Type | Description |
313 |-----------|------|-------------|
314 | `security` | string | Nonce: `cartflows_json_search_coupons` |
315 | `term` | string | Coupon code/title search term |
316
317 ---
318
319 ## Common Settings AJAX (`admin-core/ajax/common-settings.php`)
320
321 **Class:** `CartflowsAdmin\AdminCore\Ajax\CommonSettings`
322
323 **Permission:** `cartflows_manage_settings` (stricter than flows)
324
325 ### `cartflows_save_global_settings`
326
327 Save global CartFlows settings. Routes to tab-specific save methods.
328
329 | Parameter | Type | Description |
330 |-----------|------|-------------|
331 | `security` | string | Nonce: `cartflows_save_global_settings` |
332 | `setting_tab` | string | `general`, `permalink`, `other`, `user_role_manager`, `integrations` |
333 | Tab-specific fields | mixed | Depends on `setting_tab` value |
334
335 **Tab: `general`**
336 - `_cartflows_common` — Default page builder, store checkout, other common settings
337
338 **Tab: `permalink`**
339 - `_cartflows_permalink` — Slug structure for flows and steps
340
341 **Tab: `other`**
342 - `cartflows_delete_plugin_data` — Delete on uninstall toggle
343 - `cartflows_stats_report_emails` — Enable report emails
344 - `cartflows_stats_report_email_ids` — Report recipient emails (newline-separated)
345 - `cf_analytics_optin` — Non-sensitive data tracking opt-in
346
347 **Tab: `user_role_manager`**
348 - `_cartflows_roles` — Per-role capability assignments (`access_to_cartflows` or `access_to_flows_and_step`)
349
350 **Tab: `integrations`**
351 - `_cartflows_facebook` — Facebook Pixel settings
352 - `_cartflows_google_analytics` — Google Analytics settings
353 - `_cartflows_google_auto_address` — Google Places Autocomplete
354 - `_cartflows_tiktok` — TikTok Pixel settings
355 - `_cartflows_pinterest` — Pinterest Tag settings
356 - `_cartflows_google_ads` — Google Ads settings
357 - `_cartflows_snapchat` — Snapchat Pixel settings
358
359 Fires `cartflows_admin_save_global_settings` action after saving.
360
361 ---
362
363 ### `cartflows_regenerate_css_for_steps`
364
365 Clear the dynamic CSS cache to force regeneration on next page load.
366
367 | Parameter | Type | Description |
368 |-----------|------|-------------|
369 | `security` | string | Nonce: `cartflows_regenerate_css_for_steps` |
370
371 Updates `cartflows-assets-version` option with current timestamp.
372
373 ---
374
375 ### `cartflows_track_kb_search`
376
377 Track a knowledge base search term for analytics.
378
379 | Parameter | Type | Description |
380 |-----------|------|-------------|
381 | `security` | string | Nonce: `cartflows_track_kb_search` |
382 | `search_term` | string | The search term to track |
383
384 Stores up to the last 20 searches in `cartflows_kb_searches` option.
385
386 ---
387
388 ## Related Pages
389
390 - [](REST-API-ReferenceREST-API-Reference](REST-API-Reference](REST-API-Reference)
391 - [](WordPress-Hooks-ReferenceWordPress-Hooks-Reference](WordPress-Hooks-Reference](WordPress-Hooks-Reference)
392 - [](WordPress-Plugin-StructureWordPress-Plugin-Structure](WordPress-Plugin-Structure](WordPress-Plugin-Structure)
393 - [](Architecture-OverviewArchitecture-Overview](Architecture-Overview](Architecture-Overview)
394