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:
| Script | Dependencies | Purpose |
|---|---|---|
settings.js | jQuery, jQuery UI Sortable, Select2, flatpickr | Rule/workflow CRUD, settings UI |
admin-templates.js | jQuery, settings.js | Admin template rendering |
dashboard.js | jQuery | Dashboard KPI widgets |
analytics.js | jQuery, Chart.js 4.4.0 | Analytics charts and tables |
automations.js | jQuery, admin-templates.js | Automation 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.