Hooks & Filters
PredictCart provides a set of actions and filters for extending its functionality.
Actions
predictcart_init_controllers
Fired after the conditions and methods controllers are initialized. Use this to register custom controllers.
add_action('predictcart_init_controllers', function() {
MyCustomController::get_instance();
});
predictcart_automation_before_run
Fired before an automation executes.
add_action('predictcart_automation_before_run', function($uid, $automation, $context) {
// Custom pre-execution logic
}, 10, 3);
predictcart_automation_after_run
Fired after an automation completes.
add_action('predictcart_automation_after_run', function($uid, $automation, $context, $results) {
// Custom post-execution logic
}, 10, 4);
predictcart_automation_coupon_created
Fired when an automation creates a new coupon.
add_action('predictcart_automation_coupon_created', function($post_id, $code, $meta, $automation, $context) {
// Custom coupon creation logic
}, 10, 5);
predictcart_db_indexes_added
Fired after PredictCart adds database indexes during activation.
add_action('predictcart_db_indexes_added', function() {
// Custom post-index logic
});
Filters
predictcart_profiler_enabled
Enable or disable the performance profiler.
add_filter('predictcart_profiler_enabled', function($enabled) {
return defined('WP_DEBUG') && WP_DEBUG;
});
predictcart_use_rule
Dynamically enable or disable a rule during evaluation.
add_filter('predictcart_use_rule', function($use, $rule, $params) {
if (some_condition()) {
return false; // Skip this rule
}
return $use;
}, 10, 3);
predictcart_runner_allow_create_coupons
Control whether automations can create coupons dynamically.
add_filter('predictcart_runner_allow_create_coupons', function($allow, $automation, $action, $context) {
return false; // Disable automatic coupon creation
}, 10, 4);
predictcart_runner_allow_private_webhook_ips
Override the private IP block for webhook actions.
add_filter('predictcart_runner_allow_private_webhook_ips', function($allow, $host, $ips, $automation, $action, $context) {
return $host === 'internal.company.local';
}, 10, 6);
predictcart_email_max_per_hour
Change the email rate limit for automations.
add_filter('predictcart_email_max_per_hour', function($limit) {
return 100; // Allow 100 emails per hour
});