| 1 |
# WordPress Hooks Reference |
| 2 |
|
| 3 |
CartFlows provides an extensive hook system using the `cartflows_` prefix for all actions and filters. Third-party plugins and CartFlows Pro use these hooks to extend functionality. |
| 4 |
|
| 5 |
## Actions (do_action) |
| 6 |
|
| 7 |
### Plugin Lifecycle |
| 8 |
|
| 9 |
| Hook | Arguments | Description | |
| 10 |
|------|-----------|-------------| |
| 11 |
| `cartflows_loaded` | — | Plugin is fully bootstrapped. Safe to hook functionality that requires CartFlows to be ready. | |
| 12 |
| `cartflows_update_before` | — | Fires before an automatic plugin update runs. | |
| 13 |
| `cartflows_update_after` | — | Fires after an automatic plugin update completes. | |
| 14 |
|
| 15 |
### Frontend Page Hooks |
| 16 |
|
| 17 |
| Hook | Arguments | Description | |
| 18 |
|------|-----------|-------------| |
| 19 |
| `cartflows_wp` | `$step_id` | Fires on `wp` action when the current page is a CartFlows step. | |
| 20 |
| `cartflows_wp_footer` | — | Fires in the footer of CartFlows step pages. | |
| 21 |
|
| 22 |
### Checkout Page Hooks |
| 23 |
|
| 24 |
| Hook | Arguments | Description | |
| 25 |
|------|-----------|-------------| |
| 26 |
| `cartflows_checkout_scripts` | — | Enqueue checkout-specific scripts. | |
| 27 |
| `cartflows_checkout_form_before` | `$checkout_id` | Before the checkout form renders. | |
| 28 |
| `cartflows_checkout_cart_empty` | `$checkout_id` | When the cart is empty on a checkout step. | |
| 29 |
| `cartflows_add_before_main_section` | `$checkout_layout` | Before the main checkout container. | |
| 30 |
| `cartflows_add_after_main_section` | — | After the main checkout container. | |
| 31 |
| `cartflows_primary_container_bottom` | — | At the bottom of the primary checkout container. | |
| 32 |
| `cartflows_checkout_before_shortcode` | `$checkout_id` | Before rendering checkout shortcode (editor preview). | |
| 33 |
|
| 34 |
### Thank You Page Hooks |
| 35 |
|
| 36 |
| Hook | Arguments | Description | |
| 37 |
|------|-----------|-------------| |
| 38 |
| `cartflows_thank_you_scripts` | — | Enqueue thank you page scripts. | |
| 39 |
| `cartflows_woocommerce_order_overview_cancelled` | `$order` | When an order is cancelled on the thank you page. | |
| 40 |
|
| 41 |
### Opt-in Hooks |
| 42 |
|
| 43 |
| Hook | Arguments | Description | |
| 44 |
|------|-----------|-------------| |
| 45 |
| `cartflows_optin_before_shortcode` | `$checkout_id` | Before rendering optin shortcode (editor preview). | |
| 46 |
|
| 47 |
### Elementor Integration Hooks |
| 48 |
|
| 49 |
| Hook | Arguments | Description | |
| 50 |
|------|-----------|-------------| |
| 51 |
| `cartflows_elementor_before_checkout_shortcode` | `$checkout_id` | Before Elementor checkout widget renders. | |
| 52 |
| `cartflows_elementor_before_optin_shortcode` | `$checkout_id` | Before Elementor optin widget renders. | |
| 53 |
| `cartflows_elementor_checkout_options_filters` | `$settings` | After Elementor checkout widget options are applied. | |
| 54 |
| `cartflows_elementor_optin_options_filters` | `$settings` | After Elementor optin widget options are applied. | |
| 55 |
| `cartflows_elementor_editor_compatibility` | `$post_id, $elementor_ajax` | During Elementor editor compatibility checks. | |
| 56 |
|
| 57 |
### Admin AJAX Hooks |
| 58 |
|
| 59 |
| Hook | Arguments | Description | |
| 60 |
|------|-----------|-------------| |
| 61 |
| `cartflows_admin_save_step_meta` | `$step_id` | After step meta settings are saved via AJAX. Use to trigger side effects. | |
| 62 |
| `cartflows_admin_save_global_settings` | `$setting_tab, $nonce_action` | After global settings are saved. | |
| 63 |
| `cartflows_admin_after_delete_flow` | `$flow_id` | After a flow is permanently deleted. | |
| 64 |
| `cartflows_after_save_store_checkout` | — | After store checkout status is updated. | |
| 65 |
|
| 66 |
### Template Importer Hooks |
| 67 |
|
| 68 |
| Hook | Arguments | Description | |
| 69 |
|------|-----------|-------------| |
| 70 |
| `cartflows_import_complete` | — | After a template import batch completes. | |
| 71 |
| `cartflows_after_template_import` | `$new_step_id, $response` | After a single template is imported into a step. | |
| 72 |
| `cartflows_site_import_batch_complete` | — | After a full site template import batch finishes. | |
| 73 |
|
| 74 |
### Tracking / Analytics Hooks |
| 75 |
|
| 76 |
| Hook | Arguments | Description | |
| 77 |
|------|-----------|-------------| |
| 78 |
| `cartflows_facebook_pixel_events` | — | Output custom Facebook Pixel events. | |
| 79 |
| `cartflows_google_analytics_events` | — | Output custom Google Analytics events. | |
| 80 |
| `cartflows_tiktok_pixel_events` | — | Output custom TikTok Pixel events. | |
| 81 |
| `cartflows_google_ads_events` | — | Output custom Google Ads events. | |
| 82 |
| `cartflows_pinterest_tag_events` | — | Output custom Pinterest Tag events. | |
| 83 |
| `cartflows_snapchat_pixel_events` | — | Output custom Snapchat Pixel events. | |
| 84 |
|
| 85 |
--- |
| 86 |
|
| 87 |
## Filters (apply_filters) |
| 88 |
|
| 89 |
### Admin Settings Filters |
| 90 |
|
| 91 |
| Hook | Arguments | Returns | Description | |
| 92 |
|------|-----------|---------|-------------| |
| 93 |
| `cartflows_admin_global_data_options` | `$options` | `$options` | Modify global settings data sent to the settings app. | |
| 94 |
| `cartflows_admin_flows_step_data` | `$steps` | `$steps` | Modify step data in the flow API response. | |
| 95 |
| `cartflows_admin_action_slug` | `$slug, $flow_id` | string | Change the edit step action slug. | |
| 96 |
| `cartflows_admin_localized_vars` | `$vars` | `$vars` | Modify JavaScript variables localised to admin pages. | |
| 97 |
| `cartflows_admin_save_global_settings` | Fires as action | — | See actions above. | |
| 98 |
|
| 99 |
### Admin Field Definition Filters |
| 100 |
|
| 101 |
| Hook | Arguments | Returns | Description | |
| 102 |
|------|-----------|---------|-------------| |
| 103 |
| `cartflows_admin_{type}_step_default_meta_fields` | `$fields, $step_id` | `$fields` | Modify default meta fields for a step type. Replace `{type}` with the step type (checkout, optin, etc.) | |
| 104 |
| `cartflows_admin_flow_settings` | `$settings` | `$settings` | Modify flow-level settings definitions. | |
| 105 |
| `cartflows_user_role_default_settings` | `$settings` | `$settings` | Modify default user role settings. | |
| 106 |
| `cartflows_facebook_settings_default` | `$settings` | `$settings` | Modify default Facebook integration settings. | |
| 107 |
| `cartflows_pinterest_settings_default` | `$settings` | `$settings` | Modify default Pinterest integration settings. | |
| 108 |
|
| 109 |
### Frontend / Page Rendering Filters |
| 110 |
|
| 111 |
| Hook | Arguments | Returns | Description | |
| 112 |
|------|-----------|---------|-------------| |
| 113 |
| `cartflows_remove_theme_styles` | `true` | bool | Control whether theme stylesheets are removed on CartFlows pages. Return `false` to keep theme styles. | |
| 114 |
| `cartflows_remove_theme_scripts` | `true` | bool | Control whether theme scripts are removed on CartFlows pages. | |
| 115 |
| `cartflows_load_min_assets` | `false` | bool | Return `true` to use minified assets (useful in dev). | |
| 116 |
| `cartflows_checkout_form_layout` | `$layout` | string | Modify the CSS classes applied to the checkout form wrapper. | |
| 117 |
| `cartflows_page_template` | `$template` | string | Override the page template file used for a step. | |
| 118 |
| `cartflows_is_compatibility_theme` | `$bool` | bool | Override whether the current theme triggers compatibility mode. | |
| 119 |
| `cartflows_maybe_load_font_awesome` | `true` | bool | Control Font Awesome loading on CartFlows pages. | |
| 120 |
| `cartflows_do_not_cache_step` | `true, $step_id` | bool | Return `false` to allow caching plugins to cache a specific step. | |
| 121 |
| `cartflows_enable_append_query_string` | `false` | bool | Enable passing query strings between funnel steps. | |
| 122 |
| `cartflows_may_be_append_query_strings_args` | `$strings` | array | Modify the query strings passed between funnel steps. | |
| 123 |
|
| 124 |
### WooCommerce / Cart Filters |
| 125 |
|
| 126 |
| Hook | Arguments | Returns | Description | |
| 127 |
|------|-----------|---------|-------------| |
| 128 |
| `cartflows_selected_checkout_products` | `$products, $checkout_id` | array | Modify the products added to the cart for a checkout step. | |
| 129 |
| `cartflows_checkout_next_step_id` | `$step_id, $order, $checkout_id` | int | Override which step the customer is redirected to after checkout. | |
| 130 |
| `cartflows_checkout_cart_empty_message` | `$message` | string | Customise the empty cart message on checkout pages. | |
| 131 |
| `cartflows_auto_prefill_checkout_fields` | `true` | bool | Disable auto-filling of checkout fields from customer data. | |
| 132 |
| `cartflows_supported_product_types_for_search` | `$types` | array | Add or remove product types from the product search results. | |
| 133 |
| `cartflows_skip_configure_cart` | `false` | bool | Skip cart configuration in the WooCommerce Dynamic Flow module. | |
| 134 |
| `cartflows_show_coupon_field` | `$show` | bool | Show or hide the coupon code field on checkout pages. | |
| 135 |
|
| 136 |
### Checkout UI Text Filters |
| 137 |
|
| 138 |
| Hook | Arguments | Returns | Description | |
| 139 |
|------|-----------|---------|-------------| |
| 140 |
| `cartflows_woo_billling_text` | `$text` | string | Customise the billing section heading. | |
| 141 |
| `cartflows_woo_your_order_text` | `$text` | string | Customise the "Your Order" section heading. | |
| 142 |
| `cartflows_woo_shipping_text` | `$text` | string | Customise the shipping section heading. | |
| 143 |
|
| 144 |
### Analytics / Tracking Filters |
| 145 |
|
| 146 |
| Hook | Arguments | Returns | Description | |
| 147 |
|------|-----------|---------|-------------| |
| 148 |
| `cartflows_enable_non_sensitive_data_tracking` | `$bool` | bool | Override non-sensitive analytics tracking opt-in. | |
| 149 |
| `cartflows_get_specific_stats` | `$data` | array | Modify the analytics stats data sent to the server. | |
| 150 |
| `cartflows_view_content_offer` | `$params, $step_id` | array | Modify Facebook view content event params for offer pages. | |
| 151 |
| `cartflows_tiktok_view_content_offer` | `$params, $step_id` | array | Modify TikTok view content event params for offer pages. | |
| 152 |
| `cartflows_snapchat_view_content_offer` | `$data` | array | Modify Snapchat view content event params. | |
| 153 |
| `cartflows_is_offer_type` | `$bool` | bool | Override whether the current step is an offer type. | |
| 154 |
|
| 155 |
### Template / Import Filters |
| 156 |
|
| 157 |
| Hook | Arguments | Returns | Description | |
| 158 |
|------|-----------|---------|-------------| |
| 159 |
| `cartflows_templates_url` | `$url` | string | Override the CartFlows template library API URL. | |
| 160 |
| `cartflows_licence_args` | `[]` | array | Add licence arguments to template API requests. | |
| 161 |
| `cartflows_template_import_meta_data` | `$meta` | array | Modify post meta before it is saved during template import. | |
| 162 |
| `cartflows_image_importer_skip_image` | `false, $attachment` | bool | Skip importing a specific image during template import. | |
| 163 |
|
| 164 |
### Misc Filters |
| 165 |
|
| 166 |
| Hook | Arguments | Returns | Description | |
| 167 |
|------|-----------|---------|-------------| |
| 168 |
| `cartflows_enable_setup_wizard` | `$bool` | bool | Control whether the setup wizard is displayed. | |
| 169 |
| `cartflows_show_deprecated_step_notes` | `false` | bool | Show notes for deprecated step features. | |
| 170 |
| `cartflows_file_mod_disabled` | `$bool` | bool | Override file modification restriction check. | |
| 171 |
|
| 172 |
--- |
| 173 |
|
| 174 |
## Usage Examples |
| 175 |
|
| 176 |
### Redirect to a custom page after checkout |
| 177 |
|
| 178 |
```php |
| 179 |
add_filter( 'cartflows_checkout_next_step_id', function( $step_id, $order, $checkout_id ) { |
| 180 |
if ( /* custom condition */ ) { |
| 181 |
return get_page_by_path( 'custom-thankyou' )->ID; |
| 182 |
} |
| 183 |
return $step_id; |
| 184 |
}, 10, 3 ); |
| 185 |
``` |
| 186 |
|
| 187 |
### Keep theme styles on CartFlows pages |
| 188 |
|
| 189 |
```php |
| 190 |
add_filter( 'cartflows_remove_theme_styles', '__return_false' ); |
| 191 |
``` |
| 192 |
|
| 193 |
### Add custom products to checkout |
| 194 |
|
| 195 |
```php |
| 196 |
add_filter( 'cartflows_selected_checkout_products', function( $products, $checkout_id ) { |
| 197 |
if ( $checkout_id === 456 ) { |
| 198 |
$products[] = wc_get_product( 789 ); |
| 199 |
} |
| 200 |
return $products; |
| 201 |
}, 10, 2 ); |
| 202 |
``` |
| 203 |
|
| 204 |
### Run code after a step is saved |
| 205 |
|
| 206 |
```php |
| 207 |
add_action( 'cartflows_admin_save_step_meta', function( $step_id ) { |
| 208 |
// Clear your custom cache |
| 209 |
delete_transient( 'my_plugin_step_cache_' . $step_id ); |
| 210 |
} ); |
| 211 |
``` |
| 212 |
|
| 213 |
--- |
| 214 |
|
| 215 |
## Related Pages |
| 216 |
|
| 217 |
- [](REST-API-ReferenceREST-API-Reference](REST-API-Reference](REST-API-Reference) |
| 218 |
- [](AJAX-API-ReferenceAJAX-API-Reference](AJAX-API-Reference](AJAX-API-Reference) |
| 219 |
- [](WooCommerce-IntegrationWooCommerce-Integration](WooCommerce-Integration](WooCommerce-Integration) |
| 220 |
- [](Feature-ModulesFeature-Modules](Feature-Modules](Feature-Modules) |
| 221 |
- [](WordPress-Plugin-StructureWordPress-Plugin-Structure](WordPress-Plugin-Structure](WordPress-Plugin-Structure) |
| 222 |
|