Order Actions Reference

surecart/order_created

This event occurs whenever an order is created. This can happen when a customer makes a purchase during checkout, when a subscription renews, or when a subscription is updated.

do_action(
	'surecart/order_created',
	(\SureCart\Models\Order::class) $order,
	(array) $webhook_data
)

How to use

add_action( 'surecart/order_created', 'orderCreated' );
function orderCreated( $order, $webhook_data = [] ) {
  //
}

surecart/order_paid

This event occurs whenever an order is paid for.

do_action(
	'surecart/order_paid',
	(\SureCart\Models\Order::class) $order,
	(array) $webhook_data
)

surecart/checkout_confirmed

This event takes place when a customer has successfully completed their order, including making the payment.

do_action( 'surecart/checkout_confirmed', $checkout, $request );

How to use

add_action( 'surecart/checkout_confirmed', 'orderConfirmed' );
function orderConfirmed( $checkout, $request ) {
  //
}

$checkout param

{
  "id": "ad8f4942-fd69-4c71-86cd-c46fd2548a78",
  "object": "checkout",
  "abandoned_checkout_enabled": true,
  "abandoned_checkout_return_url": null,
  "amount_due": 2900,
  "applied_balance_amount": 0,
  "credited_balance_amount": 0,
  "currency": "usd",
  "discount_amount": 0,
  "email": "[email protected]",
  "first_name": null,
  "free_shipping_choice_shortage_amount": null,
  "full_amount": 2900,
  "group_key": null,
  "ip_address": null,
  "last_name": null,
  "live_mode": true,
  "manual_payment": false,
  "metadata": {},
  "name": null,
  "phone": null,
  "paid_at": null,
  "payment_method_required": true,
  "processor_data": {
    "paystack": null,
    "mollie": null,
    "paypal": null,
    "stripe": null
  },
  "proration_amount": 0,
  "reusable_payment_method_required": false,
  "shipping_address_required": false,
  "selected_shipping_choice_required": false,
  "shipping_amount": 0,
  "shipping_enabled": false,
  "status": "draft",
  "subtotal_amount": 2900,
  "tax_amount": 0,
  "tax_enabled": false,
  "tax_exclusive_amount": 0,
  "tax_label": null,
  "tax_inclusive_amount": 0,
  "tax_percent": 0,
  "tax_status": "disabled",
  "total_amount": 2900,
  "total_savings_amount": 0,
  "trial_amount": 0,
  "billing_address": null,
  "charge": null,
  "customer": "4076659d-265c-4bd5-9060-747c14fa8058",
  "discount": null,
  "manual_payment_method": null,
  "order": null,
  "payment_intent": null,
  "payment_method": null,
  "shipping_address": null,
  "tax_identifier": null,
  "selected_shipping_choice": null,
  "created_at": 1694542177,
  "updated_at": 1694542177
}

Difference between surecart/order_created and surecart/purchase_created

surecart/order_created

When a checkout is updated to the paid status, we create a purchase record for each line_item in the checkout, and then the surecart/purchase_created hook fires.

surecart/purchase_created

When a checkout is updated to the paid status, we create a purchase record for each line_item in the checkout, and then the surecart/purchase_created hook fires.

Summary:
An order will belong to a checkout, and a paid checkout can have multiple purchases associated with it.