Skip to main content

JS Events

PredictCart interacts with WooCommerce's Store API and injects data into frontend cart responses. Custom frontend implementations can read this data for custom displays.

Store API Data Injection

When using WooCommerce Blocks or a custom Store API client, PredictCart adds the following fields to cart item responses:

{
"items": [
{
"key": "abc123",
"product_id": 42,
"quantity": 2,
"price": 8.50,
"subtotal": 17.00,
"predictcart_final_unit": 8.50,
"predictcart_orig_unit": 10.00,
"predictcart_saving": 3.00
}
],
"predictcart_cart_contents_total": 17.00
}

Public JS (Frontend)

A lightweight script (public-descriptions.js) is enqueued on the frontend to display rule descriptions to customers. It depends on jQuery.

Admin JS

The admin interface uses several JS files:

ScriptDependenciesPurpose
settings.jsjQuery, jQuery UI Sortable, Select2, flatpickrRule/workflow CRUD, settings UI
admin-templates.jsjQuery, settings.jsAdmin template rendering
dashboard.jsjQueryDashboard KPI widgets
analytics.jsjQuery, Chart.js 4.4.0Analytics charts and tables
automations.jsjQuery, admin-templates.jsAutomation management UI

Store API Data Injection

When using WooCommerce Blocks or a custom Store API client, PredictCart adds adjusted pricing data to cart responses. The predictcart_final_unit and predictcart_orig_unit fields can be used in custom templates to show original price strikethroughs or savings badges.