Skip to main content

REST API

PredictCart integrates with WooCommerce's Store API and provides AJAX endpoints for admin operations.

WooCommerce Store API

PredictCart injects additional fields into Store API cart responses, enabling block themes and custom frontends to display adjusted prices.

Additional Response Fields

Each cart item in the Store API response may include:

FieldTypeDescription
predictcart_final_unitfloatThe adjusted per-unit price after rules
predictcart_orig_unitfloatThe original per-unit price before adjustments
predictcart_savingfloatTotal savings for this line item

Top-Level Cart Fields

FieldTypeDescription
predictcart_cart_contents_totalfloatCart total reflecting PredictCart adjustments

Endpoints Modified

  • /wc/store/v1/cart
  • /wc/store/v1/cart/items
  • /wc/store/v1/checkout

Admin AJAX Endpoints

All AJAX endpoints require a valid nonce (predictcart_nonce) and manage_woocommerce capability:

ActionMethodDescription
predictcart_get_rulesGETFetch all rules
predictcart_save_rulePOSTCreate or update a rule
predictcart_delete_rulePOSTDelete a rule
predictcart_duplicate_rulePOSTDuplicate a rule
predictcart_save_orderPOSTReorder rules (drag & drop)
predictcart_get_analyticsGETFetch analytics data
predictcart_get_rule_performanceGETFetch per-rule performance metrics
predictcart_get_customer_segmentsGETFetch customer segment data
predictcart_get_trendsGETFetch discount trend data
predictcart_get_workflow_activityGETFetch workflow activity data
predictcart_run_automationPOSTRun an automation manually
predictcart_schedule_automationPOSTSchedule an automation
predictcart_unschedule_automationPOSTUnschedule an automation
predictcart_export_rulesPOSTExport rules as JSON
predictcart_export_automationsPOSTExport automations as JSON
predictcart_export_settingsPOSTExport settings as JSON
predictcart_export_allPOSTExport all data as JSON
predictcart_import_dataPOSTImport data from JSON
predictcart_save_settingsPOSTSave plugin settings
predictcart_get_notificationsGETGet notification suggestions
predictcart_get_productsGETSearch products (Select2)
predictcart_get_product_categoriesGETSearch categories (Select2)
predictcart_get_customersGETSearch customers
predictcart_get_rolesGETGet user roles
predictcart_get_countriesGETGet country list
predictcart_get_shipping_classesGETGet shipping classes
predictcart_get_shipping_zonesGETGet shipping zones
predictcart_get_product_attributesGETGet product attributes

All AJAX endpoints are accessed via admin-ajax.php with the action parameter.